[plt-scheme] Macro ellipsis question

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

On Tue, Jan 27, 2009 at 9:25 AM, James Coglan <jcoglan at googlemail.com> wrote:
>
>> > (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) ...)
>
> Could someone second this? I thought I saw multi-statement templates in some
> examples though I can't remember where. R5RS would seem to agree with Sam
> but I'd like to be sure. Also, my main question was whether this macro would
> actually expand in the way I expect. The mzscheme repl seems to confirm all
> the above but if someone knows anything about other rules in other Schemes
> I'd like to know.

Also, for general questions about how things should expand, I highly
recommend the "Macro Stepper" tool in DrScheme.  It will give you the
answer you're looking for in this case, and in many other more
complicated cases as well.

-- 
sam th
samth at ccs.neu.edu


Posted on the users mailing list.