[plt-scheme] Controlling execution in macro defining macros

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Thu Jun 24 08:20:22 EDT 2004

Noel Welsh wrote:
> Thanks.  Your suggestion works, though I don't understand
> the pattern (_ actual (... ...)).  If I'm reading the docs
> correctly (... ...) is a PLT extension to syntax-rules
> that creates a pattern variable called ... 

I think the (... ...) to insert a ... comes from syntax-case.
All Schemes that use Dybvig's portable syntax-case support
(... ...).

> that matches 0
> or more times.  I don't understand why this is necessary,
> as opposed to (_ actual ...)

You need (... ...) in macro-generating macros. In (_ actual ...)
means "insert what the 'actual ...' matched in the template".
If there is no occurence of actual in an enclosing template
you get an error.

Since you are generating a macro the ... is supposed to be
inserted literally. A special syntax is needed, and for some
reason (... ...) is used to insert a literal ... .

[If you are defining a macro that generates a macro-generating
macro, you'll need ((... ...) (... ...)) .]

Page 6 of <http://www.cs.utah.edu/classes/cs6520/macro-tutorial.pdf>
has a simple example.

See also the srfi draft

   <http://srfi.schemers.org/srfi-46/srfi-synrules-exts.txt>

and the discussion.

-- 
Jens Axel Søgaard





Posted on the users mailing list.