Hi!
> You do not need gensyms if you try to mimic or implement my suggested #. .
> On the
> other hand when if you do this
>
> (define (f stx) #`(let ((x 1)) #,stx))
>
> and use this with
>
> #`(let ((x 2)) #,(f #'x))
OK, got it, thanks!
(In case others wonder, the complete example is:
(define (f stx)
#`(let ((x 1)) #,stx))
(define-syntax foo
(lambda (s)
(syntax-case s ()
((_)
#`(let ((x 2)) #,(f #'x))))))
(foo)
=> 1
)
The situation can be diagnosed with:
(define (f stx)
#`(let ((x 1))
#,(if (bound-identifier=? stx #'x) (error) stx)))
But it doesn’t help.
> (with-syntax ((x (datum->syntax stx (gensym "x")))) #`(let ((x 2)) #,(f
> #'x))))))
Often, you could use ‘generate-temporaries’, which is a bit nicer.
> Hope that this makes things clear!
It does, thanks!
It’s true that it’s annoying that the wrong binding is silently used.
Do you think it’s common enough to justify new syntax?
Thanks,
Ludo’.