in reply to Re^2: Lexical scope vs. postfix loops (perl bug?)
in thread Lexical scope vs. postfix loops (perl bug?)
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Lexical scope vs. postfix loops (perl bug?)
by jethro (Monsignor) on Aug 25, 2008 at 20:47 UTC | |
by moritz (Cardinal) on Aug 25, 2008 at 21:03 UTC | |
by jh (Beadle) on Aug 25, 2008 at 21:13 UTC | |
by moritz (Cardinal) on Aug 25, 2008 at 21:20 UTC | |
|
Re^4: Lexical scope vs. postfix loops (perl bug?)
by JadeNB (Chaplain) on Aug 26, 2008 at 16:31 UTC | |
by moritz (Cardinal) on Aug 26, 2008 at 16:49 UTC |