I think my question can be best understood by example -- what
does the following produce?
my @a = 1,2,3,4,5;
for @a { .say; @a = (); }
My question is whether the change to @a inside the for loop
affects the iterator created at the beginning of the for loop.
In other words, would the above
HaloO,
Jon Lang wrote:
Actually, note that both infix:<,> and circumfix:<[ ]> can be used to
build lists; so [1] and [] can be used to construct single-element and
empty lists, respectively.
I doubt that. Actually, circumfix:<[ ]> builds arrays. And note that
there's no infix operator that con
On Tue, Sep 09, 2008 at 10:10:04AM -0500, Patrick R. Michaud wrote:
: I think my question can be best understood by example -- what
: does the following produce?
:
: my @a = 1,2,3,4,5;
: for @a { .say; @a = (); }
:
: My question is whether the change to @a inside the for loop
: affects th
HaloO,
Patrick R. Michaud wrote:
My question is whether the change to @a inside the for loop
affects the iterator created at the beginning of the for loop.
Since Larry said that single assignment semantics is the ideal
we should strive for, I would opt for the iterator being unaffected
by the
My take on it:
The 'for' loop does bind $_ to alias each item of the list in turn.
But, "the list" is not synonymous with the variable named @a. However,
the = operator operates on "the list" itself, not the container,
replacing the elements in the existing Array (or whatever) object. So,
TSa Thomas.Sandlass-at-vts-systems.de |Perl 6| wrote:
Since Larry said that single assignment semantics is the ideal
we should strive for, I would opt for the iterator being unaffected
by the assignment to @a. When this happens the singly assigned
former content of @a is snaphot by the iterator.
Ter, 2008-09-09 às 10:10 -0500, Patrick R. Michaud escreveu:
> I think my question can be best understood by example -- what
> does the following produce?
> my @a = 1,2,3,4,5;
> for @a { .say; @a = (); }
The problem actually becomes more evident with
my @a = 1,2,3,4,5;
for @a { .say;