kawa-commonlisp-dev
[Top][All Lists]
Advanced

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

Re: [Kawa-commonlisp-dev] [GSoC] Destructuring bind


From: Per Bothner
Subject: Re: [Kawa-commonlisp-dev] [GSoC] Destructuring bind
Date: Tue, 31 Jul 2012 21:43:08 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120717 Thunderbird/14.0

On 07/31/2012 03:32 PM, Charles Turner wrote:
First buglet I'm not sure how to fix!

DEFVAR appears to be broken. The spec  says it should establish it's
name argument as a special variable. But it doesn't seem to:

(defvar *avar* 10)
(defun readit () (display *avar*))
(let ((*avar* 15))
   (readit))
;-> 10

Whereas I think it should output 15. I don't see anything special
being done in defvar.java. My question then is, is there a flag or
something similar I can set in Declaration to get this behavior?

defvar is fine, I think.  The problem is let.
It translates to a LetExp.  However, in this case we want it
to translate to a FluidLetExp.

The complication is that in CommonLisp a single let may bind
some variables lexically  (normal case) and some fluidly (if
declared special).  We could merge the functionality of
FluidLetExp into LetExp, handling different variables
differently, but that's a fairly major change.  One can
simulate the effect this way - assume:

(declare (special v2 v4))
(let ((l1 e1)
      (v2 e2)
      (l3 e3)
      (v4 e4))
  body)

as:
(let ((l1 e1)
      (tmp2 e2)
      (l3 e3)
      (tmp4 e4))
   (fluid-let ((v2 tmp2)
               (v4 tmp4))
      body))

(Note you shouldn't need to actually generate symbols for tmp2 or tmp4;
just generate Declarations with a null name.)
--
        --Per Bothner
address@hidden   http://per.bothner.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]