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

defun and lexical environments



Am I wrong or should the following be equivalent:

(defun foo (x)
 (defun bar (y) (list x y))
 x)

(defun foo (x)
 (setf (symbol-function 'bar) #'(lambda (y) (list x y)))
 x)

When I do the second form followed by (foo 1) (bar 2)
I get (1 2) returned from bar.  But doing this after the
first defun gives an error, unbound variable x.
Is this a bug in the Symbolics implementation?
Or a bug in me?

Incidentally, I am talking about the Common Lisp language
and defun is explained on p.67 of Steele (not 57 as the
index claims).  As I read it, the two forms above should
be equivalent.

 -Kurt Godden (godden@gmr.com)

p.s. If any of you have any influence in the matter, please
     try to get us a decent index in the next edition of Steele.