Re: [racket-users] Strip the lexical context from an identifier

2019-02-25 Thread Michael Ballantyne
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

Re: [racket-users] Strip the lexical context from an identifier

2019-02-23 Thread Stefano Lande
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. >

Re: [racket-users] Strip the lexical context from an identifier

2019-02-22 Thread Matthias Felleisen
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

Re: [racket-users] Strip the lexical context from an identifier

2019-02-22 Thread Sam Caldwell
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 (

Re: [racket-users] Strip the lexical context from an identifier

2019-02-22 Thread Matthias Felleisen
> 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: > > > (