[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DEFUN inside LET
> From @SU-AI.ARPA:NGALL@G.BBN.COM Thu Jan 30 11:27:51 1986
>
> > Also, since DEFUN is a macro, it's hard to imagine what it could expand
> > into in order to behave much differently from this.
>
> Imagine this:
>
> (defmacro simple-defun (name lambda-list &body body)
> `(setf (symbol-function ',name)
> '(lambda ,lambda-list ,@body)))
>
> The quote in front of the lambda ensures that the lambda expression is
> defined in the null lexical environment.
Wouldn't one instead use:
(defmacro simple-defun (name lambda-list &body body)
`(setf (symbol-function ',name)
(function (lambda ,lambda-list ,@body))))
This would seem to capture the lexical environment quite unambiguously.
If, as DCP suggests, a defun that captures its lexical environment is
really a "time bomb", defun could be "fixed". But how could it be
possible to prohibit constructions like the above?