On Apr 25, 2016, at 3:08 PM, Matthias Felleisen <[email protected]> wrote:
>> A macro that wants to put identifiers in a binding position MUST produce the
>> whole binding form for those identifiers.
>
> In the end and in general, yes.
>
> In the special case when you already have a macro whose interface can be
> extended to incorporate extensions (such as match), then you might be able to
> sneak in expansions in binding positions.
FWIW the use case here is a problem I've come across in #lang building: taking
a parse tree produced by a reader and cleaning it up into a lovely, cruft-free
S-expression before passing it to the expander.
Suppose the #lang allows binding syntax like so:
var x, y, z;
Suppose further I have a tokenizer and grammar-based parser that hands me a
tree that looks in part like so:
(var-declaration "var" (var-list x "," y "," z) ";")
Suppose further that `var-declaration` and `var-list` are macros that remove
this cruft and leave simply:
(x y z)
Elsewhere in the expander, a binding form awaits, its interface abstracted from
details of a particular parse tree:
(define-syntax-rule (define-ids (id ...))
(begin
(define id #f) ...))
Which can be called like so:
(define-ids (x y z))
So the question is how to compose these forms. The intuition is to feed
`define-ids` the relevant bit of the parse tree:
(define-ids (var-declaration "var" (var-list x "," y "," z) ";"))
--
You received this message because you are subscribed to the Google Groups
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.