[plt-scheme] binding in template
;Hi, From the example below it seems that in the template of a syntax-
case rule not only pattern variables are pattern-bound, but also
variables introduced in binding positions within the template itself.
This is most convenient. Can it be trusted to work in general?
Greetings, Jos koot.
(define-syntax (monkey stx)
(define (gen-expr x y) #`(list #,x #,y))
(syntax-case stx ()
((monkey x) #`(let ((y 0)) #,(gen-expr #'x #'y)))))
(define-values (a x y) (values 10 20 30))
(monkey a) ; --> (10 0)
(monkey x) ; --> (20 0)
(monkey y) ; --> (30 0)