[racket] Macros with Flexible Sub-Forms like (class...)
On 2013-02-23 12:34:58 -0800, Scott Klarenbach wrote:
> Thanks Danny. There's also something I recall for validation, as in the
> docs for (define/override...) where usage outside of a (class...) form is
> a syntax error. I'll hunt...:)
You can just bind the sub-forms to syntax transformers that raise
errors. For example,
(define-syntax name (syntax-rules ()))
or, more informatively:
(define-syntax (name stx)
(raise-syntax-error 'name "only valid inside new-person"))
and then provide `name` from your library. If you do this, it's probably
best to use `~literal` instead of `~datum` in your parse patterns.
Cheers,
Asumu