On Thu, 12 May 2005, Willem Broekema wrote:

>
> Gisle S�lensminde:
>> When I use the loop macro to itterate over the values or keys of a hash
>> table together with the collect keyword, I can only use one expression
>> in the body.
>> If i use do instead of collect, or wraps the expressions in a progn,
>> everything works fine. It also works fine if I use do instead of collect,
>> but the same error occurs when I use sum.
>>
>> Is this a bug in the loop macro implementation in CMUCL or is it incorrect
>> usage of the loop macro (or both :-)
>
> The LOOP syntax is defined that way. Besides, the meaning of `collect
> (foo) (bar)' is ambiguous: which of the two return values do you really
> want to collect?
>
> Take a look at the CLHS entry for this macro, and you'll find `do' takes
> `compound-form+' while `collect' takes `form'.
>
> In the example, to collect both return values, use two collect statements;
> to collect only one, use prog1 or progn.

Of some reason I thought that multiple expression in the collect worked for
(loop for elt in list... and other loop statement but not for hash tables. Now 
I 
see that this happens for all kind of looping as long as I use collect. I 
expected that multiple expressions behaved like an implicit progn.

Thanks for the help.

>
> - Willem
>
>
>

-- 
Gisle S�lensminde, Phd student, Scientific programmer
Computational biology unit, University of Bergen, Norway
Email: [EMAIL PROTECTED] | Complicated is easy, simple is hard.


Reply via email to