in reply to Re^3: Hard syntax error or disambiguable parsing?
in thread Hard syntax error or disambiguable parsing?
Case 4 is in fact identical to case 3, since $v in both cases is already a 'my' variable, subject to lexical scoping.
That doesn't make sense to me. If anything, if I understand the documentation, Case 2 and 3 are almost identical and Cases 1 and 4 are almost identical.
In Cases 1 and 2, there is no indication about whether the outer, enclosing scope (outside of the scope of the foreach loop) there is any variable $v wandering around. Since it is not shown, I would presume that the intent is that no such varible exists in exterior scope(s). And I'm not sure that it really matters, in the context of what I'm thinking.
But, if I understand the documentation, in Cases 1 and 4, the use of my in the creation of the loop variable results in a lexically scoped variable and it never appears in any package symbol table.
However, in the situations in Cases 2 and 3, the loop variable is created as if it were created with a local construct. In which case the $v exists in the package symbol table, but a copy is created and used within the scope of the loop and the original value of $v is not touched. At the end of the loop's scope, the original value of $v is restored to the variable in the package symbol table.
So the difference, it seems to me, is whether the package symbol table's variables (symbols?) are used or a new, unseen (by the package symbol table) variable (symbol?) are created for the duration of the loop's scope.
For me, that would seem to make Cases 2 & 3 almost identical and Cases 1 & 4 almost identical.
But then, I'm still learning and could be wrong.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Hard syntax error or disambiguable parsing?
by shmem (Chancellor) on Jan 29, 2009 at 21:32 UTC | |
by ig (Vicar) on Jan 30, 2009 at 00:41 UTC | |
by BrowserUk (Patriarch) on Jan 30, 2009 at 02:54 UTC | |
by rovf (Priest) on Jan 30, 2009 at 08:52 UTC | |
by BrowserUk (Patriarch) on Jan 30, 2009 at 09:19 UTC | |
by shmem (Chancellor) on Jan 30, 2009 at 14:21 UTC | |
by shmem (Chancellor) on Jan 30, 2009 at 13:59 UTC | |
by gone2015 (Deacon) on Jan 30, 2009 at 11:09 UTC |