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

2013-05-17 Thread Asumu Takikawa
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


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

2013-05-17 Thread Carl Eastlund
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 as...@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


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


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

2013-05-17 Thread Asumu Takikawa
On 2013-05-17 19:51:00 -0400, Carl Eastlund wrote:
 That's where the rename comes from.

Ah, thanks! I should've looked closer at the expansion.

(also thankfully it turns out I didn't need any complicated
 set!-transformer manipulation to do what I was trying to do)

Cheers,
Asumu
_
  Racket Developers list:
  http://lists.racket-lang.org/dev