[plt-scheme] Macro ellipsis question

From: Sam TH (samth at ccs.neu.edu)
Date: Tue Jan 27 08:36:27 EST 2009

On Tue, Jan 27, 2009 at 8:06 AM, James Coglan <jcoglan at googlemail.com> wrote:
> Hi all,
>
> I've a quick question about macros. I'm doing my own Scheme implementation
> and trying to figure out macros from R5RS and PLT docs. My question is: is
> the following a valid macro, assuming you provide equal numbers of symbols
> and values?
>
> (define-syntax parallel-set!
>   (syntax-rules ()
>     [(parallel-set! (symbol ...) (value ...))
>       (set! symbol value) ...]))
>
> (parallel-set! (a b c) (1 2 3))
> ; a = 1, b = 2, c = 3

Only one form is allowed in the template portion of `syntax-rules',
but you have two: (set! symbol value) and ... .

You probably want

(begin (set! symbol value) ...)

instead.

Hope that helps,
-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.