On Thu, Nov 20, 2003 at 03:26:36PM -0700, Luke Palmer wrote:
> No. gather{} is a generator (assuming nothing about its name or
> existance whatsoever). It runs some code, gathering up each pick()
> (same assumption) into a list, and returning that.
Thanks for the post Luke. I'd seen what Larry wrote, but for some
reason it didn't click until you wrote this. I think part of that is
because I was thinking of generators something like this:
sub foo :generator { while $cond { ... yield $foo; } }
@list = &foo;
Where the declaration and use were separate (in my fantasy here,
assigning a coderef to a list makes lazy eval happen). What was
throwing my brain I think it that gather is a declaration and "call"
all rolled into one.
> If I interpret Larry correctly, Damian's semantics won't be going in.
> The way you get each of those is:
>
> my @list = gather {
> while $cond {
> pick do {...}
> }
> }
That makes much more sense the synapse firing that was previously
happening in my head :-)
> One wonders what the return value of a loop will be:
>
> my $what = do {
> while $cond {...}
> }
I would expect it to be the value of the last statement executed.
-Scott
--
Jonathan Scott Duff
[EMAIL PROTECTED]