[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

packages, lexical variables, and compiling



Consider the file foo.lisp:

	(IN-PACKAGE "MYPACKAGE")
	(DEFUN FOO (X)
	  (LET ((X-PLUS-1 (1+ X)))
	    (LIST X X-PLUS-1)))

Loading foo.lisp into any common lisp has the side effect of creating
package MYPACKAGE if it does not yet exist, and also creating symbols
MYPACKAGE::FOO, MYPACKAGE::X, and MYPACKAGE::X-PLUS-1 if any of these
do not exist.  So much is clear.

If foo.lisp is compiled to produce foo.bin, and foo.bin is later loaded
into a different lisp world, clearly package MYPACKAGE and symbol
MYPACKAGE:FOO must be created if they do not yet exist.  But what about
symbols MYPACKAGE::X and MYPACKAGE::X-PLUS-1 ?

The existence of symbols naming these lexical variables is not required
for execution of the function.  (A clever compiler could even optimize
X-PLUS-1 away.)  Still, it is easy for a program to tell whether these
symbols exist, and it is possible to construct package interlocutions
which will fail depending on whether or not the symbols are created.

There are three possibilities:
 1 - CLtL requires that the symbols are created (although some
     implementations fail to do so), preserving interpreter-compiler
     consistency.
 2 - CLtL requires that the symbols not be created, which saves storage
     but loses interpreter-compiler consistency.
 3 - CLtL explicitly leaves it up to the implementation.

Unless I have missed something, CLtL is silent on the matter.  This is
*not* quite the same as leaving it up to the implementation.  Should
the language definition be more specific?