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

just a question



    Date: Thu, 3 Dec 87 11:05:13 -0200
    From: Moshe Cohen <moco@wisdom.bitnet>

    Why is it not possible to set an array element to the result of
    the COMPILE function as in:

     (SETF (AREF ARRAY-NAME 1) (COMPILE NIL #'(LAMBDA () 'F)))  .

    The following error message is received:

       Trap: The argument given to the CAR instruction,
	#<LEXICAL-CLOSURE (LAMBDA NIL #) 40303466>,
       was not a locative, a list, or NIL.


    It IS possible to do it with an auxiliary variable to hold the
    result or by using what I understand as a NOOP:

     (SETF (AREF ARRAY-NAME 1) (EVAL '(COMPILE NIL #'(LAMBDA () 'F))))


    Moshe Cohen.

Use ' instead of #'.  The second argument to COMPILE is supposed to be a
lambda-expression, not a lexical closure.  The SETF form expands into a
LET, so in the first case the interpreter must create a lexical closure
for the #'(lambda...).  In the second case this isn't necessary because
EVAL defaults to the null lexical environment, so in that case
#'(lambda...) is equivalent to '(lambda...).

                                                barmar