[racket] Macros and literal-id

From: Vincent St-Amour (stamourv at ccs.neu.edu)
Date: Tue Aug 9 10:51:55 EDT 2011

At Tue, 09 Aug 2011 08:25:14 -0600,
Richard Cleis wrote:
> What is the reason for using syntax-rules instead of syntax-parse?
> (To maintain RnRs compatibility?)

When simple pattern-matching and templating can express what you want,
syntax-rules (and even define-syntax-rule) is great and very easy to
use and read.

When your macro needs to do more involved computation, that's when
syntax-parse really starts to shine.

As a rule of thumb, I usually try to write macros with
define-syntax-rule first, then syntax-rules if it's not enough, and
then syntax-parse for the more complicated cases.

Vincent


Posted on the users mailing list.