This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Package initialisation in CL boot


* Charles Turner [2012-07-03 21:38] writes:

> I've found it quite tricky to figure out exactly how other ANSI CL's
> do this. The general theme appears to be to export all standard
> symbols at boot time, and define them later. This matches how you use
> DEFPACKAGE. 

Right, typically the package structure (i.e. symbol-names, exports,
imports etc.) is set up once at the beginning and not changed
afterwards.  This is also how a typical CL library is made: packages are
defined first with DEFPACKAGE; explicit uses of EXPORT or IMPORT are
rather uncommon.

E.g. in SBCL there is a file common-lisp-exports.lisp-expr that lists
all standard symbols (there are similar files for the exported
non-standard symbols) and this is used to set up the symbols before
compiling the compiler.

> For the other standard library symbols, it seems to be the
> case that the implementation interns the symbols in a "system" package
> (SBCL uses "SB!IMPL", ABCL uses one called "SYSTEM"), and then export
> the library functions from Lisp using (export 'something) at
> definition time.

No, symbols are usually not exported at definition time.  E.g.

  (defun foo (x) (bar))

does something like

  (setf (symbol-function 'foo) (lambda (x) (bar)))

at load time.  At load time, the symbol FOO either already exists or if
not is interned (but not exported) in the package that FOO had at
compile time.  Setting the function slot doesn't export the symbol.

> What I'm a little confused about is whether all the
> standard symbols need to be interned *as well as* being exported. It
> shouldn't make any difference in finding the symbols, but am I missing
> something else?

The standard symbols need to be exported, otherwise one couldn't write
things like CL:CONS.  The "home package" of CL:CONS needs to be CL
otherwise it would not be printed as CL:CONS but something like
SYSTEM:CONS.  I'm not sure if it needs to be interned in CL; probably
not.

Helmut


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]