<meta content="text/html; charset=ISO-8859-1"
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">This is what syntax-parameters are for.<br>
(define-syntax-parameter m (lambda (stx) (raise-syntax-error 'm
"dont use this outside deeper")))<br>
(define-syntax-rule (deeper e)<br>
(syntax-parameterize ([m (lambda (stx) #'1)])<br>
(deeper (m)) -> 1<br>
On 10/16/2012 04:18 PM, John Clements wrote:<br>
<pre wrap="">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:
;; I want m's meaning to depend on its context
(define-syntax (m stx)
(define-syntax (deeper stx)
(syntax-case stx ()
;; I want to change the meaning of m, here:
(set-box! the-box 16)
;; 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 :).
Racket Users list:
<a class="moz-txt-link-freetext" href="http://lists.racket-lang.org/users">http://lists.racket-lang.org/users</a>