On Wed, Nov 19, 2003 at 12:49:21PM -0800, Larry Wall wrote: > Sorry, I wasn't being very clear. It wouldn't be logically attached to > the outside of the for, but to the inside of the "confer", or whatever: > > @foo = gather { > for @a -> $x { pick $x if mumble($x) } > DEFAULT { @results } > }
So ... the only way to get Damians semantics ... On Wed, Nov 19, 2003 at 08:01:40AM +1100, Damian Conway wrote: > * vector control structures like C<loop>, C<while>, and C<for> in > a list context return a list of the values of the last statement > each iteration evaluated; > > * vector control structures like C<loop>, C<while>, and C<for> in > a scalar context return an integer indicating the number of > times their block was iterated. ... is to surround the control structure with a gather { ... } ?? It seems like "gather" or whatever should be some sort of modifier to for/loop/while/until @foo = for : gather @a -> $x { ... } if for : gather @a -> $x { ... } < 3 { ... } # ick! if : gather for : gather @a -> $x { ... } < 3 { ... } # ick!**2 for : gather @a -> $x { ... } or @results; for : gather @a -> $x { ... } or do { ... } Okay, so the syntax isn't great. I'm just brainstorming. Having a gather block just feels wrong to me. It's weird to say that control structure X only has a result when placed inside of a special block. But maybe it *needs* to be weird. > On the other hand, putting the default up front is clearer if the > block is long. Could even be something like: > > @foo = gather is default(@results) { > for @a -> $x { pick $x if mumble($x) } > } Hmm. @foo = for :gather,default(@results) @a -> $x { ... } -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]