in reply to Re^2: Hard syntax error or disambiguable parsing?
in thread Hard syntax error or disambiguable parsing?
but for $i ( 0 .. 5 ) is not a foreach loop as defined in perlsyn.
It's good to know that someone else around here actually reads the docs--and arrives at the same interpretation as me.
Personally, the whole 'unavoidable implicit localisation' of for loop variables smacks of an accidental implementation bug that got post-facto ligitimisation via Marketeer Maintainenance: The re-branding of bugs as features.
There doesn't seem to be any logical reason why an existing variable shouldn't be used (unlocalised) as the loop iterator, given that if a strictly loop scoped iterator is required, the inline-my version achieves that perfectly.
This would allow several common uses that currently require extra steps to achieve. For example, retaining the information of how far the loop iterated if it is terminated early via last, that currently requires an extra variable and another assignment.
If this was an explicit decision--rather than an accidental happenstance as suggested by some of the comments in the source files--then it would be good to see the reasons laid out.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Hard syntax error or disambiguable parsing?
by TimToady (Parson) on Jan 30, 2009 at 19:11 UTC | |
by BrowserUk (Patriarch) on Jan 30, 2009 at 19:55 UTC |