[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pika-dev] Problem with Pika's macro expander?
From: |
Matthew Dempsky |
Subject: |
Re: [Pika-dev] Problem with Pika's macro expander? |
Date: |
25 Feb 2004 11:05:58 -0600 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Tom Lord <address@hidden> writes:
> So that the pattern/template from LETREC
>
> ((letrec "gtn"
> (x y ...)
> (temp ...)
> ((var1 init1) ...)
> body ...)
>
> (letrec "gtn"
> (y ...)
> (newtemp temp ...)
> ((var1 init1) ...)
> body ...))
>
> can be translated to a transformer as:
>
> (let ((y... (cdr (list-ref exp 2)))
> (temp... (cdr (list-ref exp 3)))
> (var1-init... (list-ref exp 4))
> (body... (cddddr (cdr exp)))
> (_newtemp_ (hygenic-binding-of newtemp)))
>
> `(letrec "gtn"
> ,y...
> ,temp...
> ,var1-init...
> ,@ body...))
I think you actually meant (let bindings omitted):
`(letrec "gtn"
,y...
(,_newtemp_ ,@temp...)
,var1-init...
,@ body...))
Also, for the record, I'd like to point out that there should be just
one call to hygenic-binding-of per symbol when expanding a
syntax-rules clause. For example, the following clause is part of the
R5RS syntax-rules definition of OR:
((or test1 test2 ...)
(let ((x test1))
(if x x (or test2 ...))))
It's important to expand that into:
(let ((test1 (cadr exp))
(test2... (cddr exp))
(_let (hygenic-binding-of let))
(_x (hygenic-binding-of x))
(_if (hygenic-binding-of if))
(_or (hygenic-binding-of or)))
`(,_let ((,_x ,test1))
(,_if ,_x ,_x (,_or ,@test2...))))
rather than:
(let ((test1 (cadr exp))
(test2... (cddr exp))
(_let (hygenic-binding-of let))
(_x1 (hygenic-binding-of x))
(_x2 (hygenic-binding-of x))
(_x3 (hygenic-binding-of x))
(_if (hygenic-binding-of if))
(_or (hygenic-binding-of or)))
`(,_let ((,_x1 ,test1))
(,_if ,_x2 ,_x3 (,_or ,@test2...))))
I doubt the above would be a likely expansion that anyone would
generate, but equivalent semantics might be formed by a naive
implementation.
-jivera