[racket-dev] some surprising behavior with syntax-parameterize and lexical info

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Fri Apr 6 17:05:29 EDT 2012

> (define-syntax (def stx)
>  (syntax-case stx ()
>   [(_ (name args ...) body ...)
>    (with-syntax ([function-stx stx])
>      (syntax/loc stx
>        (define (name args ...)
>          (splicing-syntax-parameterize ([current-def
>                                          (quote-syntax fuunction-stx)])
>            body ...))))]))
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> ....Wait, what?

To follow up on this, change the test code at the bottom to:

(let ()
  (define x 42)
  (def (f x) (* (outer x) x))
  (f 2))

and you'll see an error here with your version.  My apologies for not
having this more robust test case in place.


Posted on the dev mailing list.