[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Kawa-commonlisp-dev] tagbodies
From: |
Charles Turner |
Subject: |
Re: [Kawa-commonlisp-dev] tagbodies |
Date: |
Fri, 27 Jul 2012 13:02:20 +0100 |
On 26 July 2012 21:12, Jamison Hope <address@hidden> wrote:
> LABELS is very similar to Scheme's letrec, so I would expect the
> amount of work to get a working LABELS to be about what you had to do to
> make FLET based on LET (i.e. not too much).
Hm, unsurprisingly I am having difficulties :). My problem is that
LETREC just SET!'s a lexical variable to a lambda. That causes
problems for LABELS because then to use the function you have to
FUNCALL (or similar) it. Think we need to do a SetExp#setFuncDef or
similar, but that would require a change to the LETREC macro. Maybe I
should just copy the thing in my primitives file and somehow modify it
to to call this method?
>
> For now, it'd probably be faster to just manually convert each TAGBODY to
> an equivalent LABELS; later on, when we actually need to implement
> TAGBODY...
>
> As Helmut said, we'll need something like escape analysis to ignore anything
> coming after a GO statement, which we could do now with Scheme's call/cc:
>
> CLHS has this example:
>
> (let (val)
> (tagbody
> (setq val 1)
> (go point-a)
> (incf val 16)
> point-c
> (incf val 04)
> (go point-b)
> (incf val 32)
> point-a
> (incf val 02)
> (go point-c)
> (incf val 64)
> point-b
> (incf val 08))
> val)
> => 15
>
> If I were writing TAGBODY for Scheme, I would probably write it with
> syntax-case and have it transform that into something like this:
Thanks Jamison! That's really neat. I will definitely postpone this
for now, but that will come in very handy later me thinks. :)
> +1, unless the compiler fix is trivial (sounds like Per thought it might
> be?).
I did attempt it and as I expected ran into inliner errors saying it
couldn't find the LambdaExp#keyword field (I'm guessing because I
generalised the type from Keyword[] to Symbol[]). I wasn't sure where
to start looking for this, so I decided to leave it for now.
Thanks for all the help,
Charles.
Re: [Kawa-commonlisp-dev] tagbodies, Charles Turner, 2012/07/27