On Sun Mar 20 08:30:28 2016, awwaiid wrote:
> Here is an example that works as expected:
> 
>     > for ^2 { my $n = 5; say [+] (^$n X ^$n) }
>     50
>     50
> 
> If we use constants to construct the Seq, it is not re-created on the
> second loop iteration:
> 
>     > for ^2 { say [+] (^5 X ^5) }
>     50
>     This Seq has already been iterated, and its values consumed
>     (you might solve this by adding .cache on usages of the Seq, or
>     by assigning the Seq into an array)
>       in block <unit> at <unknown file> line 1
> 
> In my particular case after building the Seq I was applying map and grep to
> it which would change on each iteration -- it yells at me for the
> constant-Seq re-use even though I am doing different things with it each
> time.
> 
Yeah, it was a constant folding issue. I've now made sure we don't try to do 
that for things that produce a Seq, which fixes the issue. Test added to 
S03-metaops/cross.t.

Reply via email to