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: Charles Turner
Subject: Re: [Kawa-commonlisp-dev] [GSoC] Destructuring bind
Date: Wed, 1 Aug 2012 20:21:13 +0100

On 1 August 2012 05:43, Per Bothner <address@hidden> wrote:
> 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.

Ah, thanks Per. I've opted to proceed by using FLUID-LET from Scheme
for the time being. I've made a note to fix the problem at a later
point.

> 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))

And I suppose you'd conditionally generate the temporaries based on
the fact that {v2,v4}.isFluid is true? I think that's all the SPECIAL
directive would have to do, just call Declaration#setFluid(true),
right?

----
The destructuring bind is progressing. I have parse-defmacro mostly
working. Had some nasty bugs because of my keeping the lowercase form
of names from other parts of Kawa, so

(defun f (&key when) (list when))
(f :when <whatever>)

would always return (#f) due to Keywords#searchForKeywords not
matching when to WHEN. This is all very unfortunate, but for the time
being I'm using names like when1, even  though the proper fix should
be fairly easy. Trying to eliminate distractions as much as possible!
Currently I can get neat things like:

#|kawa:1|# (parse-defmacro '(x &key y) 'whole-1 '((list x y)) 'test
'defmacro :error-fun #'error :anonymousp ())
(let* ((KEYWORDS-2 (CDR (CDR WHOLE-1))))
 (MULTIPLE-VALUE-BIND (PROBLEM-4 INFO-5)
  (VERIFY-KEYWORDS KEYWORDS-2 (quote (KEYWORD:Y)) (quote ()))
  (when PROBLEM-4
   (#<procedure error> (quote DEFMACRO-LAMBDA-LIST-BROKEN-KEY-LIST-ERROR) :KIND
    (quote DEFMACRO) :NAME1 (quote TEST) :PROBLEM PROBLEM-4 :INFO INFO-5)))
 (let ((ARGS-3 (CDR WHOLE-1)))
  (unless (LIST-OF-LENGTH-AT-LEAST-P ARGS-3 1)
   (#<procedure error> (quote ARG-COUNT-ERROR) :KIND (quote DEFMACRO) :NAME1
    (quote TEST) :ARGS ARGS-3 :LAMBDA-LIST (quote (x &KEY Y)) :MINIMUM 1
    :MAXIMUM ())))
 (let*
  ((x (CAR (CDR WHOLE-1)))
   (Y
    (if (KEYWORD-SUPPLIED-P KEYWORD:Y KEYWORDS-2)
     (LOOKUP-KEYWORD KEYWORD:Y KEYWORDS-2) ())))
  (list x Y))) () () 1 ()

Charles.



reply via email to

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