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

EVAL



    Date: Wed, 26 Nov 86 11:10 est
    From: mike at acorn
        Date: Wed, 26 Nov 86 00:24:12 EST
        From: Alan Bawden <ALAN at AI>
        ...  How do you compile
        
          (defun bind-x-then-call-f (x f)
            (funcall f `(cons x x)))...

    I just write

    (defun bind-x-then-call-f (x f)
       (eval `(funcall ,f '(cons ,x ,x)))...

I presume you mean this to be

  (defun bind-x-then-call-f (x f)
    (eval `(funcall ',f '(cons ',x ',x)))).

The quotes prevent an extra evaluation I doubt you intended.

You can't rewrite BIND-X-THEN-CALL-F this way because before your rewrite
it was the case that:

  (bind-x-then-call-f 7 #'cadr)  ==>  X

but afterwords:

  (bind-x-then-call-f 7 #'cadr)  ==>  (QUOTE 7)