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

Re: Defmacro inside of a let



	Date: Sat, 1 Feb 1986  10:13 EST
	Message-Id: <RAM.12179900850.BABYL@C.CS.CMU.EDU>
	From: Rob MacLachlan <RAM@C.CS.CMU.EDU>
	To: OLDMAN@USC-ISI.ARPA
	Cc: common-lisp@SU-AI.ARPA
	Subject: Defmacro inside of a let
	
	
	    That's because the compiler wants to be able to evaluate macros at
	compile time.  It would be impossible to compute the lexical
	environment of a macro definition without actually interpreting the
	surrounding code.  This is basically impossible, and is almost
	certainly not what you want.  It is more obvious in the case of
	MACROLET, which is usually embedded in random code somewhere.  This is
	explained to some degree on page 114.

I may be missing something here, but it seems to me that the compiler 
wants to process ALL toplevel forms at compile time. Of course the
compiler would have to interpret the surrounding code to calculate the
lexical environment. I don't see why this is basically impossible. This
is exactly what was being discussed in the recent "Defun inside LET"
controversy. As for not being what the programmer wanted, what about
the person that wants to (for whatever reason) write the following:

(let ((counter 0))
  (defmacro conditional-expand (...args...)
     (incf counter)
     (if (< counter *some-level*)
         `(an expansion)
         `(another expansion))))

I'm not defending this code, or even saying that this is the only way
to do such a thing, but what's wrong with it linguistically?

	    [...]

	  Rob

Rob