From the keyboard of Dan Book [10.06.21,04:24]:
> > for my ($a, $b, undef) ((1,2,3)) { … } # one iteration or syntax error--
>
> Right. This is the interesting question...
>
> I'm suggesting syntax error.
>
> I think the slightly better question would be express it as
>
> for my ($a, undef, $c) (1 .. 9) { ... }
>
>
> It's a reasonable generalisation of list assignment, where you can assign to
> undef to mean "ignore this value". I can see that this *might* be useful.
> It's also safe syntax to implement (although I didn't try, and I'm not sure
> how hard it would be).
>
> I'd like to stick to forbidding this, because it makes the implementation
> harder.
>
>
> I also see how it could be useful, but on the other hand it is exactly the same in practice
> as my ($x, $y, $z) but with some (imagined or real) microoptimization of not aliasing the
> second value/using up that variable name. I don't think it's useful enough to outweigh
> complication to the implementation.
And it would introduce an exception of a general rule for little gain.
Targets for assignments must be lvalues. Assigning to undef, a literal
or a constant is prohibited.
If assigning to 'undef' in that special case is permitted, the following
should also be permitted
for my ($first, "banana", $last) (@snacks) { ... }
and so the "must be lvalue" rule would deteriorate from that end.
0--gg-
--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
> > for my ($a, $b, undef) ((1,2,3)) { … } # one iteration or syntax error--
>
> Right. This is the interesting question...
>
> I'm suggesting syntax error.
>
> I think the slightly better question would be express it as
>
> for my ($a, undef, $c) (1 .. 9) { ... }
>
>
> It's a reasonable generalisation of list assignment, where you can assign to
> undef to mean "ignore this value". I can see that this *might* be useful.
> It's also safe syntax to implement (although I didn't try, and I'm not sure
> how hard it would be).
>
> I'd like to stick to forbidding this, because it makes the implementation
> harder.
>
>
> I also see how it could be useful, but on the other hand it is exactly the same in practice
> as my ($x, $y, $z) but with some (imagined or real) microoptimization of not aliasing the
> second value/using up that variable name. I don't think it's useful enough to outweigh
> complication to the implementation.
And it would introduce an exception of a general rule for little gain.
Targets for assignments must be lvalues. Assigning to undef, a literal
or a constant is prohibited.
If assigning to 'undef' in that special case is permitted, the following
should also be permitted
for my ($first, "banana", $last) (@snacks) { ... }
and so the "must be lvalue" rule would deteriorate from that end.
0--gg-
--
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}