The `syntax-local-introduce` solution breaks when the macro is used from a
different module.
The datum->syntax solution may or may not have the behavior you are looking
for:
#lang racket
(module a racket
(require (for-syntax syntax/parse))
(require (for-syntax racket/syntax))
(define
Thanks to both of you, it is exactly what I was trying to do.
Stefano
Il giorno ven 22 feb 2019 alle ore 18:37 Matthias Felleisen <
matth...@felleisen.org> ha scritto:
>
> And that’s better of course because you pick up the lexical scope, which
>
> (let ([x 4]) [(my-macro x) 1 2])
>
> shows.
>
And that’s better of course because you pick up the lexical scope, which
(let ([x 4]) [(my-macro x) 1 2])
shows.
> On Feb 22, 2019, at 1:26 PM, Sam Caldwell wrote:
>
> You can also do this with syntax-local-introduce to remove x's use-site
> scope*:
>
> #lang racket
>
> (require (fo
You can also do this with syntax-local-introduce to remove x's use-site
scope*:
#lang racket
(require (for-syntax syntax/parse))
(define-syntax (my-macro stx)
(syntax-parse stx
[(_ x:id)
#:with x- (syntax-local-introduce #'x)
#'(lambda (a b) x-)]))
((my-macro a) 1 2)
;; 1
(
> On Feb 22, 2019, at 1:08 PM, Stefano Lande wrote:
>
> Dear all,
>
> first of all, I might being misusing the terminology. Sorry about it.
>
> I would like to write a macro that gets an identifier and return its value in
> the new lexical scope created by the macro.
> For example:
>
> > (
5 matches
Mail list logo