Do you know why a specific behavior is not defined?I think that there's no one consistent way to define one. Usually variables are block scoped, so making my $x for @list behaving the same as do { my $x } for @list is just weird.
One could argue that $stuff for @list should always be the same as for @list { $stuff }, but then you could write
use strict; print $x*$x for my $x (0..10);
Which seems equally weird, because a variable is used (textually)before it is declared. (And I don't know if that's technically possible in the perl compiler).
So regardless from which angle you look at it, it smells badly. So the behaviour is not defined. Maybe someday a hero of programming languages will find something that's consistent in every way, and then it can be still implemented.
In reply to Re^3: Lexical scope vs. postfix loops (perl bug?)
by moritz
in thread Lexical scope vs. postfix loops (perl bug?)
by jh
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |