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

From: Ryan Culpepper (ryan at cs.utah.edu)
Date: Thu Apr 5 23:10:44 EDT 2012

On 04/05/2012 08:31 PM, Danny Yoo wrote:
>> If that doesn't seem clear, can you explain more your line of reasoning
>> that they should be the same?
> I guess I'm having a hard time with this: I want to get the value of
> a-placeholder into the place marked ??? in the following:
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define-syntax (def stx)
>   (syntax-case stx ()
>     [(_ (name args ...) body ...)
>      (let ([a-placeholder (datum->syntax stx 'placeholder)])
>        (quasisyntax/loc stx
>          (splicing-syntax-parameterize ([current-def ???])
>            (define (name args ...)
>              body ...))))]))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> a-placeholder is a compile-time expression, so I expected to be able
> to somehow bind current-def to it, but I'm hitting "indentifer used
> out of context" errors when I do so.
> I suspect that I should be using quote-syntax at this specific point,
> but I am not completely sure.

Right. Try replacing ??? with (quote-syntax #,a-placeholder).

I've written about "out of context" errors here: 
(Warning: that page is okay, but most of the other pages are now quite 


Posted on the dev mailing list.