[racket] macros whose meaning is dependent on context?
This seems like a straightforward question; apologies if I just haven't dug deep enough to find the answer.
I want to define a macro whose meaning depends on its context. More specifically, I want to define an "outer" macro that gives a particular meaning to the "inner" macro.
I can see how to get the job done in a yucky way, using mutation:
#lang racket
;; I want m's meaning to depend on its context
(define-syntax (m stx)
#`#,(unbox the-box))
(define-syntax (deeper stx)
(syntax-case stx ()
[(_ arg)
;; I want to change the meaning of m, here:
(set-box! the-box 16)
#'arg]))
;; yucky mutation-based way to get the job done
(define-for-syntax the-box (box 13))
(deeper (m 134))
… but it seems like there must be a simple way for the outer binding to say "whatever meaning the inner macro wants it to have".
Don't tell me, it's define-for-inner-syntax/local-expand. I just made that up, so I hope it's wrong :).
John
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4800 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20121016/8cd3eb85/attachment.p7s>