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


   Subject: compiler-let
   From: David A. Moon <hplabs!Moon@STONY-BROOK.SCRC.Symbolics.COM>
       Date: Mon, 7 Jul 86 15:13 EDT
       From: Jonathan A Rees <JAR@MIT-AI.ARPA>
       COMPILER-LET seems pretty confused; CLtL says that it is intended
       "for communication among complicated macros," but as far as I can tell
       it doesn't reliably serve this end, since its effect is not the same in
       interpreted and compiled code.  Consider the following example:
   	(defvar *foo* nil)
   	(defmacro foo () `',*foo*)
   	(defun test ()
   	  (compiler-let ((*foo* t))
   	    #'(lambda () (foo))))
       Now if TEST is "interpreted," then (funcall (test)) presumably returns
       NIL; if it's "compiled," then (funcall (test)) presumably returns T.
   It always returns T in the implementation on my machine.

It also always returns T on my machine (HP Common Lisp).
   But I see your point.  If the macro foo was not expanded until after the
   closure was made, and if the interpreter failed to include the COMPILER-LET
   information in the closure, it would return NIL.

I certainly agree with Jonathan that as stated in CLtL, COMPILER-LET is
bogus.  When implementing this special form, we determined that (if we
were to believe the intent stated for COMPILER-LET) the bindings must be in
effect in the same context that the macroexpansion will occur.  The statement
made in CLtL for the compiler is correct as all Common Lisp implementations
are required to expand macros at compile time (see page 143).  However,
the statement that COMPILER-LET behaves like LET in the interpreter implictly
assumes that macros are expanded at eval time in the interpreter.  Since this
is not true in our implementation, we had to decide what was needed to make
COMPILER-LET perform as needed.  This meant that for our implementation,
COMPILER-LET does the same thing whether interpreted or compiled (it sets
up bindings in the preprocessor environment -- which is when macroexpansion
occurs in our system).

I am not sure whether COMPILER-LET should remain in the language or not, but
I think that the correction to the description which I mentioned does make
it meaningful (although terribly misnamed).