On 02/26/2014 01:54 PM, Matthew Butterick wrote:
Thank you. Maybe I can make the question a tiny bit less dumb (though still 
really dumb).

In this example, when I use the syntax macro 'public-proc', it keeps the 
'private-proc' binding from the 'inner' submodule.

Q: How could I invoke 'public-proc' for its syntax-generating effect in the 
main module, yet have it adopt the binding of 'private-proc' in the main module?

I gather roughly that it requires tampering with the lexical information of the 
syntax objects. Then things get hazy.
I think you are looking for define-macro, so that you can defeat hygiene. Of course this comes with all of the normal caveats about the dangers of breaking hygiene, so if this is what you're looking for, can you describe why you want to do it?

Example:

;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket

(module inner racket
  (provide public-proc public-proc2)
  (require compatibility/defmacro)
  (define-syntax-rule (public-proc x) (private-proc x))
  (define (private-proc x) (format "Inner private proc says ~a" x))
  (define-macro (public-proc2 x) `(private-proc ,x)))

(require 'inner)

(define (private-proc x) (format "Outer private proc says ~a" x))

(syntax->datum (expand #'(public-proc 'hi)))
;> '(#%app private-proc 'hi)
(public-proc 'hi)
;> "Inner private proc says hi"

(public-proc2 'hi)
;> "Outer private proc says hi"


(syntax->datum (expand #'(private-proc 'hi)))
;> '(#%app private-proc 'hi)
(private-proc 'hi)
;> "Outer private proc says hi"


Thanks,
Dave

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

Reply via email to