From: Tobias C. Rittweiler
Subject: Re: Changing non-special variable to special affects closures
Date:
Message-ID: <87prg4tvo1.fsf@freebits.de>
········@gmail.com writes:
> ;; SBCL:
> (let ((v1 "closure"))
> (defun f1 () v1))
> (f1) ; -> "closure"
>
> (defparameter v1 "special")
> v1 ; -> "special"
>
> (f1) ; -> "closure"
> ;; OK this is what I was expecting
>
> ;; NOW CLISP
> (let ((v1 "closure"))
> (defun f1 () v1))
> (f1) ; -> "closure"
>
> (defparameter v1 "special")
> v1 ; -> "special"
>
> (f1) ; -> "special"
> ;; WHY???
You do not compile F1, so in your call of F1 its definition is
interpreted in a context where V1 is special.
I haven't looked up whether the standard mandates anything about this,
or leaves this undefined. If the latter, it's a cute example of the
difference between interpreted and compiled code.
-T.
On Mar 26, 11:39 am, "Tobias C. Rittweiler" <····@freebits.de.invalid>
wrote:
> ········@gmail.com writes:
> > ;; SBCL:
> > (let ((v1 "closure"))
> > (defun f1 () v1))
> > (f1) ; -> "closure"
>
> > (defparameter v1 "special")
> > v1 ; -> "special"
>
> > (f1) ; -> "closure"
> > ;; OK this is what I was expecting
>
> > ;; NOW CLISP
> > (let ((v1 "closure"))
> > (defun f1 () v1))
> > (f1) ; -> "closure"
>
> > (defparameter v1 "special")
> > v1 ; -> "special"
>
> > (f1) ; -> "special"
> > ;; WHY???
>
> You do not compile F1, so in your call of F1 its definition is
> interpreted in a context where V1 is special.
>
> I haven't looked up whether the standard mandates anything about this,
> or leaves this undefined. If the latter, it's a cute example of the
> difference between interpreted and compiled code.
I don't remember the wording or the section, but ITIR that the spec
mandates no differences between "interpreted" and "compiled" code
(modulo the various read, macroexpand, compilation and run times).
Cheers
--
Marco