[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Lexical references in DEFMACRO
Date: 5 May 86 15:25 PDT
From: Gregor.pa@Xerox.COM
Another problem with having the lexical environment of a defmacro'd
macro be the null environment is that you can't "macroize for speed" the
following perfecly reasonable coding style:
(let ((unique-id "foo"))
(defun make-foo () (list unique-id () () ()))
(defun foo-p (x) (and (listp x) (eq (car x) unique-id))))
Specifically, you couldn't turn the defun of foo-p into the seemingly
obvious defmacro.
I think if you actually write out the seemingly obvious defmacro, you
will see that it's not so:
(defmacro foo-p (x) `(and (listp ,x) (eq (car ,x) unique-id))))
which does not reference unique-id as a variable from the body of
the macro, only from the expansion of the macro.
Of course the inline proclamation was made to order for this. I wonder
if it was intended to work for things not at top level. This can of
worms should not be dealt with piecemeal.