On 06/30/2011 05:01 AM, Carl Eastlund wrote:
On Wed, Jun 29, 2011 at 10:55 PM, Matthew Flatt<mfl...@cs.utah.edu> wrote:
The problem with having the macro transformer add `syntax-protect' for
(define-syntax bar
(lambda (stx) ...))
is that some other transformer can say
((syntax-local-value #'bar) stx)
to get the transformer's result without `syntax-protect' --- which was
a gaping hole that Ryan noticed in the certificate system.
We considered ways of automating `syntax-protect' for all macros, but
the ways we found seemed to create more problems than they solved.
Thank you, that greatly clarifies the issue for me. Of course I would
like to see syntax-case and syntax-parse have options to automatically
syntax-protect as well; that will cover a lot more common cases for
me. But now I can see where the trade-offs are that resulted in this
design.
Something like this springs to mind:
(define-syntax provide/protection
(syntax-rules ()
((_ name)
(begin
(define-syntax tmp
(syntax-rules ()
((_ . args) (name . args))))
(provide (rename-out (tmp name)))))))
If I understand correctly then
(provide/protection mymacro)
would automatically wrap mymacro and export it
(by virtue of redirecting the transformation through syntax-rules).
May I suggest the following introduction for the documentation?
"Nice macros you have here. Would be a pity if ... something
happened to them. But we can provide... protection."
Stephan
_________________________________________________
For list-related administrative tasks:
http://lists.racket-lang.org/listinfo/dev