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

make-lexical-environment



   Redistributed: CommonLoops.PA
   Date: Sun, 14 Feb 88 16:10:03 PST
   From: cperdue@sun.com (Cris Perdue)

   Is the following code adequate for make-lexical-environment (compared
   with the code in walk.lisp), and if not, is it inadequate for a good
   reason related to the definition of Common Lisp, or just because
   implementation quirks of some Lisps?  This code is certainly a bit
   simpler.

   (defmacro current-env (&environment e)
     `',e)

   (defun make-lexical-environment (form env)
     (evalhook
      `(,(first form)
	,(second form)		; Local macro defns
	()				; No declarations, though according to the
				   ; PCL comments, they are illegal here.
	(current-env))		; body of the macrolet
      nil nil env))

   Thanks for any info on this.

				   -Cris

In some Common Lisp implementations, the environments used in EVALHOOK
and those used in MACROEXPAND are not compatible.  This code would
take an existing EVALHOOK environment and return a MACROEXPAND
environment.  The result could not be passed to EVALHOOK again.
Furthermore, some implementations allocate environment objects on the
stack, so returning that object from CURRENT-ENV would result in
garbage.  You are probably correct in your assessment that these are
"implementation quirks of some Lisps" and not intrinsic to the Common
Lisp standard.  The operative phrase in CLtL is "The hook feature is
provided as an aid to debugging."  EVALHOOK (unlike MACROEXPAND) is
part of the programming environment rather than part of the
programming language.  This issue should be addressed by the cleanup
committee.