Re: Help with packages



vttoonses <vttoonses@xxxxxxxxx> writes:

As to question number 3, are you saying that each symbol that I wish
to use from outside the package implementation file(s) needs to be
exported explicitly?

Correct.

Exporting a class name only allows the creation
of the class (without the '::' syntax) not access to the accessor/
reader/writer methods, correct? (I'm assuming this is due to the
separation of data and behavior in the CLOS).

No, the assumption is incorrect.

Exporting applies only to SYMBOLs. It has nothing to do with classes,
slots, CLOS or anything else. Packages manage only namespaces and not
any other elements of Lisp code.

So if you have a class and a function named "FOO", then exporting the
symbol FOO means that both

(make-instance 'my-package:foo)

and

(my-package:foo ...)

can be invoked without needing to use the double colons.

Packages in lisp are only there to prevent accidental namespace
collisions. They do not purport to provide any measure of data or
implementation hiding. (As the ability to access internal symbols of
packages demonstrates.)


--
Thomas A. Russ, USC/Information Sciences Institute
.



Relevant Pages

  • More Multiple Classes per File (was Pretty Format...)
    ... Uri Guttman wrote: ... setups to exercise the limits of these paradigms. ... I think key to all of this is that packages that contain subs intended ... exporting no symbols with EXPORTER. ...
    (comp.lang.perl.misc)
  • Re: Understanding CLOS Encapsulation
    ... exporting a class name only exports the symbol. ... accessor functions. ... class may have slots from different packages. ... it is not clear which one you would want to simply refer to as SLOT-X ...
    (comp.lang.lisp)
  • Re: Image versus package savers?
    ... exporting then backing up your packages frequently, ... Things that I consider risky include: newly changed external interfacing; failure of an MVP triad to open correctly; note that you should never save an image if the dreaded prim g2 garbage collector walkback appears. ...
    (comp.lang.smalltalk.dolphin)
  • Re: Read Macro Characters and Packages
    ... I don't have the impression that changing the read table occurs so often that ... My guess would be that exporting ... wondered if perhaps the import itself was considered explicit enough. ...
    (comp.lang.lisp)