Re: lambda-returning defmacro, capture
- From: Juho Snellman <jsnell@xxxxxx>
- Date: 13 Dec 2006 19:26:15 GMT
Alex Mizrahi <udodenko@xxxxxxxxxxxxxxxxxxxxx> wrote:
(message (Hello 'Pascal)
(you :wrote :on '(Wed, 13 Dec 2006 14:15:50 +0100))
PB> Well, that's the point: there is no _standard_ way to define a global
PB> non-dynamic variable.
PB> So, it seems that both sbcl and clisp allow defining global "lexical"
PB> variables with SETF/SETQ. But this is no standard Common Lisp.
i wonder what's wrong with this:
CG-USER(1): (setf (symbol-value 'varr) 10)
CG-USER(2): (funcall (let ((varr 11)) (lambda () varr)))
ain't that "global non-dynamic variable"?
No, it is undefined behaviour. The standard specifies (in 220.127.116.11.1)
three kinds of variables, none of which VARR fits. The standard also
doesn't specify what should be done for non-variables that are used
syntactically like variables.
It happens that all implementations I know of have chosen the same
behaviour for this, and interpret VARR as referring to the value slot
of the symbol (though sometimes with warnings of an undefined variable
being used). Thus the following code will print 11, even though FOO
hasn't been declared special either globally or in the lexical scope
(setf (symbol-value 'foo) 10)
(defun bar ()
(let ((foo 11))
(declare (special foo))
So really, if you want "global lexicals", you need to use
- Prev by Date: Re: merits of Lisp vs Python
- Next by Date: Re: merits of Lisp vs Python
- Previous by thread: Re: lambda-returning defmacro, capture
- Next by thread: Re: lambda-returning defmacro, capture