On Mon, 2004-08-30 at 16:34, Rod Adams wrote: > @x = @y ==> map lc ==> grep length == 4;
I would think you actually want to be able to define grep, map, et al. in terms of the mechanism for unraveling, and just let the optimizer collapse the entire pipeline down to a single map. To propose one way of doing it (and really just a simple example off the top of my head which may not be the best idea...): macro grep(&cond, [EMAIL PROTECTED]) is mapper { if cond($_) { ($_) } else { () } } macro map(&cond, [EMAIL PROTECTED]) is mapper { cond($_) } Which would do two things: 1. Define a subroutine of the same name that does the full map: sub grep (&cond, [EMAIL PROTECTED]) is mapper { my @result; for @list -> $_ { push @result, $_ if cond($_) } return @result; } 2. Populates an optimizer table with just the macro form When you see C<grep {...} map {...} grep {...}> now, you can just consult that table and determine how much of the pipeline can be transformed into a single map. There, you're done. No more pipeline overhead from list passing. Now, of course you still have things like sort where you cannot operate on single elements, but those cases are more difficult to correctly optimize, and lazy lists won't help those either. -- â 781-324-3772 â [EMAIL PROTECTED] â http://www.ajs.com/~ajs