Luke Palmer writes:
 > 
 > for parallel(<>, 0..Inf) -> $line, $count {
 >     FIRST { $line //= "#!/usr/bin/perl" }
 >     # processing...
 >     NEXT  { print STDERR "Next line...\n" }
 >     LAST  { print STDERR "Done\n" }
 > }
 > 
....
 > 
 > Also, keep in mind that that C<parallel> function can be any (possibly
 > user-defined) function.  I really like that interface.  Also keep in
 > mind that that may not be The Interface  :( i.e. still under debate ).
 > 

is parallel ( or whatever I pu there ) *always* a lazy function or it
returns a lazy list . I dont exactly see the differnce in case of

parallel(<>, 0..Inf) . 

but in more "earthly" example 

@a  = (1,2,3); @b = qw( a b c ) ; 
for parallel(@a,@b) { $^x mumble $^y } 

will parallel *first* evaluate to ( 1 , "a" , 2, "b" , ... "c" ) 
and then for "walk" it over -- or parallel  lazyli "yeld" one value at 
a time when for request . 

what I am concerned with here is : will for - parallel pair be smart
enough to optimize away unnecessary ( and CPU - costly ) reshuffling
of @a,@b -> (@a[0], @b[0], @a[1], @b[1], ... ) . or , actually I am
talking about imaginary problem and this reshuffling happens in zero
time. ( But *I* always can write parallel-like function that will do
it *very* inefficiently . so what happens in this case )   
 
since I feel that I am not *very* clear , just one question : 

what is faster ( in perl6 ) ? 



for parallel(@a,@b) { mumble $^x, $^y } # assuming parallel stop when
                                        # one of the arrays is exhosted
or 

my $i=0;
my $x,$y; 
loop { 
        $x = @a[$i  ]  or last loop 
        $y = @a[$i++]  or last loop 
        mumble $x , $y ; 
}

arcadi 

Reply via email to