I did miss something when trying in racket, it's a psyntax bug!
Look!
racket:
(define-for-syntax (f x) #`(let ((x 1)) #,x))
> (define-syntax (g x) (syntax-case x ()((_ y) #`(let ((x y)) #,(f #'x))))
)
> (g 4)
4
In guile,
scheme@(guile-user)> (define (f x) #`(let ((x 1)) #,x))
scheme@(guile-user)> (define-syntax g (lambda (x) (syntax-case x () ((_ y) #`(let ((x y)) #,(f #'x))))))
scheme@(guile-user)> (g 4)
$1 = 1
!
I much prefer rackets version here. I will file a bug report and also try to understand what spec that racket is following!
> | It’s true that it’s annoying that the wrong binding is silently used.Sure, but it’s not good-style. ;-) In general, ‘syntax-case’ is great,
> | Do you think it’s common enough to justify new syntax?
>
> Yes this highlights a comon problem when implementing racket match with #`.
but it’s low-level plumbing to be used with care, compared to
‘syntax-rules’.
Unlike syntax-{quote,unquote,...}, #. has no non-syntax-prefixed
> I do think
> that the best solution is to somehow extend the syntax expander to mimic my
> sugested
> #. and #.@. The simple solution is to rewrite according to
>
> #`(... #.((x y) (f #'x #'y)))
>
> ->
>
> #`(let-syntax ((g (lambda (x) (syntax-case x () ((_ x y) (f #'x #'y))))))
> (... (g x y))
equivalent. And what it does is non-trivial. So I don’t feel
comfortable with this extension, FWIW.
[...]
Yes, this should be discussed on c.l.s or scheme-reports.
> I also feel that the issue needs to be
> liffted up to the
> community of at least syntax-case user crowd before doing anything Ill try
> to spur
> some discussions on it and come back later!
Thanks,
Ludo’.