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:
http://www.ccs.neu.edu/home/ryanc/macro-patterns/error_out-of-context.html.
(Warning: that page is okay, but most of the other pages are now quite
obsolete.)
Ryan
_________________________
Racket Developers list:
http://lists.racket-lang.org/dev