[racket-dev] set!-transformers and syntax-local-value/immediate

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Fri May 17 19:51:00 EDT 2013

Asumu,

Your lookup macro's output just tells whether there is a rename somewhere
between the binding for f and its original source binding.  Rename
transformers get injected all over the place.  To get the real story, turn
your lookup macro into a loop that chases the binding back to the source.
Or, use the macro stepper with hiding off.  The let-syntax expression
expands into:

        (letrec-syntaxes+values (((f1) (make-set!-transformer values))) ()
          (letrec-syntaxes+values (((f) (values (make-rename-transformer
(quote-syntax f1))))) ()
            (lookup f)))

That's where the rename comes from.

Carl Eastlund

On Fri, May 17, 2013 at 7:30 PM, Asumu Takikawa <asumu at ccs.neu.edu> wrote:

> Hi all,
>
> I'm confused about an aspect of set! and rename transformers. I'll
> explain with this example:
>
>   #lang racket
>
>   ;; a macro that uses `syntax-local-value/immediate`
>   (define-syntax (lookup stx)
>     (syntax-case stx ()
>       [(_ id)
>        (let-values ([(f _) (syntax-local-value/immediate #'id)])
>          (displayln (rename-transformer? f))
>          (displayln (set!-transformer? f))
>          #'0)]))
>
>   ;; f is a set!-transformer
>   (let-syntax ([f (make-set!-transformer values)])
>     (lookup f))
>
>   ;; sanity check
>   (rename-transformer? (make-set!-transformer values))
>
> In this example, `f` is bound to a set!-transformer. The macro `lookup`
> will look up the value bound to `f` at compile-time, and I expected that
> the result would be the set! transformer.
>
> However, it seems like the set! transformer is somehow being turned into
> a rename transformer (note the two print statements produce #t and #f
> respectively). The last line suggests that set! transformers are not
> actually a "subtype" of rename transformers though.
>
> Am I confused about set! transformers or is there a bug here?
>
> Cheers,
> Asumu
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/dev/archive/attachments/20130517/ed1aee1a/attachment.html>

Posted on the dev mailing list.