[racket] Compile-time vs. Runtime Calls to the Same Macro
Hello Robby,
"Robby Findler" <robby at eecs.northwestern.edu> said:
> I didn't try to understand your code in any detail (if this comment
> isn't helpful and no one else takes you up on this, try making a
> smaller example),
Thank you, Robby for your comment.
While trying to reproduce the issue with a simpler sequence of instructions, I noticed that the issue is caused by the presence of special keywords such as 'private' and 'public' as literal-ids in a syntax-case form.
Here's a simpler demonstration of the issue:
-------------------------------------- dispatch.rkt
#lang racket
(provide (for-syntax (all-defined-out)) (all-defined-out))
(define-syntax (dispatch stx)
(syntax-case stx ()
((dispatch form)
#'(syntax-case form (public private)
((public name val)
(λ () (displayln "I'm dispatched for public")))
((private name val)
(λ () (displayln "I'm dispatched for private")))))))
------------------------------------ test-dispatch.rkt
#lang racket
(require "check.rkt" (for-syntax "check.rkt"))
(define public-p2 (dispatch #'(public x 1))) ;; OK
(define private-p2 (dispatch #'(private x 1))) ;; OK
(define-for-syntax public-p1 (dispatch #'(public x 1))) ;; KO
(define-for-syntax private-p1 (dispatch #'(public x 1))) ;; KO
-------------------------------------------------------
If we replace 'public' and 'private' with e.g. 'foo' and 'bar', then phase-1 calls will also succeed.
I presume that keywords such as 'public' and 'private' are reserved by the Racket object system. Now, is there a way to work around this issue, so that I can make use of those keywords in my object system?
> but do you know about
>
> (require (for-template ...))
I didn't know about it but it doesn't seem to be applicable here.
Kind regards,
Sina K. Heshmati