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

Re: Lexical references in DEFMACRO

    Date: Mon, 5 May 86 20:04 EDT
    From: David A. Moon <Moon@SCRC-STONY-BROOK.ARPA>

	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.

This can of worms includes storing FOOs in binary files.  The string
which is unique-id, by Gregor's intended semantics, must be the same
in all bin files that have their roots with the make-foo above, and the
loader somehow has to know all this.  It might work in a single file,
but to do multiple files starts getting into the realm of global unique
ids and databases and so on.