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

Re: the lexical environment for DEFTYPE, DEFINE-SETF-METHOD and DEFSETF

	Date: 11 Oct 87 15:41 PDT
	From: David Bein <pyrnj!pyramid!bein@RUTGERS.EDU>

	Do functions created by DEFTYPE, DEFINE-SETF-METHOD and
	DEFSETF have the same restriction as DEFMACRO (page 145 CLtL)
	does about where the function body is effectively defined,
	i.e. would it be legal to take DEFTYPE, DEFINE-SETF-METHOD
	and DEFSETF forms and evaluate them as if <form> (wherever it
	appears) is (EVAL '<form>) ...

If I understand your question correctly, you are referring to the
sentence in the description of DEFMACRO that states that the body of a
DEFMACRO is evaluated in the null lexical environment.  This restriction
was put in with the thought that it was necessary in order for the
compiler to be able to macroexpand forms without evaluating the
surrounding code to create a lexical environment.

This argument, however, is bogus, since it is the lexical environment of
the DEFMACRO, not that of the macro-call, that is important.  If a
DEFMACRO appears in a non-null lexical environment, the compiler is not
obliged to notice it at all (aside from compiling it correctly).  That
is, later forms in the same file may not depend upon that macro having
been installed.  (On the other hand, if you then load that file, the
compilation of later files \may/ count on the macro being present.)

Regardless of all this, the restriction is still a part of the language
and so, for consistency's sake, given the understanding everyone has
about the correctness of Sandra's top-level form proposal, the same
restriction should indeed apply to the three kinds of forms you
mentioned: DEFTYPE, DEFINE-SETF-METHOD and DEFSETF.  More succinctly,
the answer to your question is yes.

On the other hand, the language would probably be better served by
removing the restriction on DEFMACRO instead.  Perhaps someday I'll get
around to proposing this to the cleanup committee...