This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
Re: Problem using #!rest in defmacro
- From: "Are Meisfjord" <are at meisfjord dot com>
- To: jason dot songhurst at valtech dot com, kawa at sources dot redhat dot com
- Date: Wed, 11 Dec 2002 15:30:32 +0100
- Subject: Re: Problem using #!rest in defmacro
Thank you, that solved my problem!
(But I still don't understand why #!rest and #!optional won't work in
macros - they work with define and lambda.)
#|kawa:19|# (set! a (lambda (b #!rest c) (list b c)))
#|kawa:20|# (a 3 4 5)
(3 (4 5))
Are
---- Original Message ----
From: jason.songhurst@valtech.com
To: are@meisfjord.com,
Subject: Re: Problem using #!rest in defmacro
Date: Tue, 10 Dec 2002 15:30:36 -0700
>Are Meisfjord wrote:
>> C:\>java kawa.repl
>> #|kawa:1|# (defmacro foo (#!rest bar) `(list ,@bar))
>> #|kawa:2|# (foo 1 2 3)
>> <stdin>:2:2: no matching case while expanding foo
>>
>> I am new to Scheme but the corresponding statement in Common Lisp
>> (using &rest instead of #!rest) works fine. Am I missing something?
>>
>
>When using lambda in scheme, you can pick up the 'rest arguments'
>with
>the tail of a dotted list.
>
>So, the formal arguments to a lambda can (only) be one of:
>* a list of variables -- (foo bar baz)
>* a variable -- foo
>* a dotted list -- (foo bar . baz)
>
>In the first case, each of the arguments is bound with the
>corresponding
>calling operand, and if the numbers of arguments and operands don't
>match, there is an error.
>
>In the second case the (single) argument is bound to a list
>containing
>all the parameters.
>
>In the third case all the arguments before the '.' are treated as in
>the
>first case, and the remaining (single) argument is treated as in the
>second case.
>
>So...
>
>(defmacro foo bar `(list ,@bar))
>
>- jason
>
>