On Fri, Sep 12, 2008 at 11:33 AM, Daniel Ruoso <[EMAIL PROTECTED]> wrote:
> In SMOP, I'm probably going to presume that everything needs to be lazy,
> then even:
>  my @o = grep { /\d+/ } =$*IN;
>  my @a = (1,2,(3,4,@o));
>  my @b = (1,2,(3,4,@a));

Can only one array "have" the iterator? If not, that makes for =$*IN {
=$*IN if $needs_skipping } look like a forbidden idiom. On the other
hand, if it's really really lazy, then I could run the following two
statements without reading anything out of the iterator

my @digitlike = grep { /\d+/ } =$*IN;
my @hexlike = grep { /<hexadecimal>+/ } =$*IN;

But, if the taking of an iterator causes the array to autoactualize
(made this word up to parallel autovivify), what happens to the other
lazy array? Does the iterator buffer its contents to be served up to
other readers, or is the $iterator.next function
first-come-first-serve? Or is there some possible "batching" behavior
that allows one of the iterators to gobble more than is used?

given a non-deterministic iterator which would return <1 2 3 a b c 5 6
7 d e f 8 9 0>
say @digitlike[0..4];
say @hexlike[0..4];     # what's this? <1 2 3 a b> or <7 d e f 8> or
<> or undefined behavior?

In the event you picked <1 2 3 a b>, when did the @hexlike grep block
get called?

- Ashley Winters

Reply via email to