for ($a, $b) { $_ = ... }
gives me a "Can't modify constant item: VRef <Scalar>". Making it
explicitly rw doesn't help:
for ($a, $b) -> $x is rw { $x = ... }
Is this a "haven't gotten around to rw parameters in blocks yet" or a
regression?
--
Mark J. Reed <mark...@mail.com>
Which is correct as the default.
: Making it explicitly rw doesn't help:
:
: for ($a, $b) -> $x is rw { $x = ... }
:
: Is this a "haven't gotten around to rw parameters in blocks yet" or a
: regression?
Not implemented, I think, but could be a regression. In any event, not
right currently.
Larry
Not according to the spec. S04 says:
> If you rely on C<$_> as the implicit parameter to a block,
> then [it] is considered read/write by default. That is,
> the construct:
>
> for @foo {...}
>
> is actually short for:
>
> for @foo -> $_ is rw {...}
Oops, sorry, was confusing implicit $_ with explicit ->$_. You are correct.
Larry
Happily, as soon as I receive it.
Upon further investigation I see that the problem is not rw parameters
per se, but the ability to pass individual lvalue items into them.
That is, this works (and a test for it is already in for.t):
my @a = (0..2); for @a { $_++ }
say @a; # 1,2,3
But this dies with the "Can't modify constant item: VRef <Scalar>" message:
my ($a,$b,$c) = 0..2; for ($a,$b,$c) { $_++; }
That may be what you fixed; I haven't built r12675 yet to see. But
it's not what I thought the problem was. :)
Done. Tests 37 (implicit "rw $_") and 38 (explicit "-> $x is rw")
add to for.t as of r12968.