Gordon Henriksen writes: > Larry Wall wrote: > > > On Tue, Nov 18, 2003 at 06:28:59PM -0500, Gordon Henriksen wrote: > > > > > my @b = for @a -> $_ { > > > ... > > > } > > > > That will be a syntax error. Generators are too mind-stretching to > > inflict on novices [...] > > I making the point that within the context of this we-wish-loops-were- > expressions discussion, the "for expression" was simply another way > to spell map, at least when autoiterating an array. > > I certainly wasn't thinking in terms of coroutines--they absolutely > deserve a large syntactic barrier.
I don't think generate{} and yield() were supposed to indicate coroutines. Instead, it's more like Mathematica's Sow[] and Reap[], which would work (Perl6-ized) as follows: @a = reap { sow 1; some-other-statement; sow 2; } # @a is (1,2) It's a nice concept; it simplifies certain kinds of list processing greatly. It would easily be implemented with coroutines, which might also explain the yield(). Luke