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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

Reply via email to