Excerpts from netnews.comp.lang.lisp: 10-Feb-93 Whither EVAL? by Len
·······@Aig.Jpl.Nasa
> (defun make-setter (code)
> (let ((v nil))
> (eval `(function (lambda ()
> (print v)
> (setq v ,code))))))
>
> Test:
> > (setq f (make-setter '(random 10)))
> #<Interpreted-function ...>
> > (funcall f)
> nil
> 9
> > (funcall f)
> 9
> 3
>
Why does this even work?
EVAL is supposed to evaluate its form in a null lexical
environment. The variable v should not be accessible.
?? Ray Pelletier