From ... From: Erik Naggum Subject: Re: More Scope... Date: 2000/02/25 Message-ID: <3160482077049507@naggum.no>#1/1 X-Deja-AN: 589894234 References: <33Dr4.39317$632.1701797@news1.rdc2.on.home.com> <88umug$fpe$1@eve.enteract.com> <3160252167384001@naggum.no> mail-copies-to: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@eunet.no X-Trace: oslo-nntp.eunet.no 951493383 13153 195.0.192.66 (25 Feb 2000 15:43:03 GMT) Organization: Naggum Software; +47 8800 8879 or +1 510 435 8604; fax: +47 2210 9077; http://www.naggum.no User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.5 Mime-Version: 1.0 NNTP-Posting-Date: 25 Feb 2000 15:43:03 GMT Newsgroups: comp.lang.lisp * Keke Abe | Could you explain the distinction? I've read the 1996 thread but could | not figure that out. a binding of a lexical variable is an entirely new variable, one that may be captured independently of any other variable, and which is not visible anywhere else. a binding of a special variable is a dynamic association between variable and value which is seen everywhere else the same variable is referenced. the reference to a lexical variable is under the supreme control of the compiler, which may allocate it to a register or to a stack frame, and which will typically discard the symbol association. the reference to a special variable is like a call to symbol-value on that symbol. this means that the statement "there may be a lexical and dynamic variable with the same name" is terribly confused. yes, it is possible to "forget" to declare a symbol special, which means any binding will be lexical, but so, then, will any normal reference. in order to access the symbol, you can no longer just name it, you need to call symbol-value or set when you want to read or change its value. but at this time, we're clearly doing something very different than what we did with variables -- we're actually tinkering with the underlying implementation of special variables. a fully true statement would be that the symbol-value slot of a symbol is accessible and may be accessed also when the symbol has not been declared special. however, using a variable means _not_ having to do anything special like that at every access, so it's clear that we access a symbol's internal information in code like this: (1) common-lisp-user ;; In Lisp Listener #2 (2) common-lisp-user (defun foobar (x) (values x (symbol-value 'x))) => foobar (3) common-lisp-user (setq x 666) => 666 (4) common-lisp-user (foobar 4711) => 4711 => 666 (5) common-lisp-user (defvar x 69) => x (6) common-lisp-user (foobar 4711) => 4711 => 4711 (7) common-lisp-user hope this helps. #:Erik