I'm working through "Let's Build a Hygienic Macro Expander!", which is
great, but I'm confused about nested quote-syntax:
#lang racket
(require (for-syntax racket))
(define x 5)
(begin-for-syntax
(define-syntax m2
(lambda (stx)
#'#'x)))
;(let ()
(define-syntax m
(lambda (stx)
#`(let ((x 6))
#,(m2))))
(m)
;)
I think the x inside #'#'x should keep its original lexical context (prints
5). But maybe quote-syntax only keeps one layer of context, so the inside
#'x gets the context where m2 was called (prints 6)?
In DrRacket 6.9, I get 6 as shown, and uncommenting that extra let ()
changes it to output 5, which seems fishy. Other ways I can think of to
write it all return 6.
Can anyone enlighten me?
Thanks,
Dave
--
You received this message because you are subscribed to the Google Groups
"Racket Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/racket-dev/CAMzh2MqVrXus54gSJpxzgFJjn7ux3mU99BS-nX-p9EY18vo4Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.