[racket-dev] Enhancement to the syntax system?

From: Ludovic Courtès (ludo at gnu.org)
Date: Tue Jul 10 11:26:24 EDT 2012

Hi,

Matthew Flatt <mflatt at cs.utah.edu> skribis:

> It's natural --- but not correct --- to think that #` is responsible
> for hygiene, in which case `(f #'x)' should keep the given `x' separate
> from the `let'-bound `x' in the result.

[...]

> If you change the example to
>
>  #lang racket
>  (begin-for-syntax 
>   (define-syntax-rule (f body)
>     #`(let ([x 1]) body)))
>  (define-syntax (m stx)
>    (with-syntax ([zz (f x)]) #`(let ([x 2]) zz)))
>  (m)
>
> so that `f' is used as a macro instead of a function, then you get 2,
> since the macro-expansion of `(f x)' keeps the `x's separate.

Interesting.  Thanks for the clarification and examples.

Ludo’.


Posted on the dev mailing list.