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

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Fri Apr 6 16:59:47 EDT 2012

On Fri, Apr 6, 2012 at 4:13 PM, Michael W <mwilber at uccs.edu> wrote:
> This seems to work for me, printing 84, just like you expect:
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (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 ...))))]))

"fuunction-stx" is misspelled here, so this can't do what I want, to
send a syntax object with the lexical context, function-stx, in as the
argument to the splicing-syntax-parameterize.  Every attempt I've
tried so far unintentionally absorbs the lexical context of its
immediate surroundings.

I was going to write a small tutorial about this example in:


but because I'm fundamentally missing something here, I can't publish
until I really do understand what I'm getting wrong... :(

Posted on the dev mailing list.