[racket] keyword arguments in define-syntax-rule

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Wed Aug 10 13:25:12 EDT 2011

Keyword arguments in function headers and applications are constrained
to take a single argument; macro patterns in syntax-case (which
define-syntax-rule is based on) and syntax-parse are more flexible in
how they can use keywords.  Making them accept keyword arguments would
remove this flexibility.  I suspect you could write a new form for
parsing macros with function-header-like patterns, however.
Alternately, use define-simple-macro from syntax/parse/define and
parse keyword arguments with ~optional and ~seq.

Carl Eastlund

On Wed, Aug 10, 2011 at 12:58 PM, Jon Rafkind <rafkind at cs.utah.edu> wrote:
> Can `define-syntax-rule' support keyword arguments? Preferably keywords
> with default values.
>
> (define-syntax-rule (foo #:x [x 5]) x)
> (foo)
> (foo #:x 2)
>
> If this sounds like a good idea and could be implemented I can give it a
> whirl.


Posted on the users mailing list.