Using lisp displa to view local variables



Stavros Macrakis <macrakis at alum.mit.edu> wrote:

   Common Lisp has lexical scope, so (eval 'x) evaluates x in the global scope (by default).

This is incorrect.  Assuming x has not been declaimed special, (eval 'x)
has no defined semantics at all in ANSI CL.  This bit of language
lawyering doesn't much matter, since it happens that every known
implementation does what you say (some may warn).  But that is a matter
of convenience and back compatibility, not the semantics of CL.

This is in sbcl:

 * (setf (symbol-value 'x) 123)

 123
 * (funcall (lambda () x))

 ; ==>
 ;   #'(LAMBDA () X)
 ; 
 ; caught WARNING:
 ;   undefined variable: X
 ; 
 ; compilation unit finished
 ;   Undefined variable:
 ;     X
 ;   caught 1 WARNING condition

 123