in reply to Re^2: Hard syntax error or disambiguable parsing?
in thread Hard syntax error or disambiguable parsing?

for $i ( 0 .. 5 ) is not a foreach loop

May I ask you in what way

for $i ( 0 .. 5 )
and
foreach $i ( 0 .. 5 )
differ, according to your opinion? perlsyn says The "foreach" keyword is actually a synonym for the "for" keyword, so I don't see how you came to the idea that the for loop your mention, would not be a foreach loop. Did I miss something here?

-- 
Ronald Fischer <ynnor@mm.st>

Replies are listed 'Best First'.
Re^4: Hard syntax error or disambiguable parsing?
by ikegami (Patriarch) on Jan 29, 2009 at 13:40 UTC

    Did I miss something here?

    You probably think the ".." in "for[each] $i ( 0 .. 5 )" is the range operator and that it creates a list of 6 elements. It's not, and no list of 6 elements is created.

    perlsyn distinguishes between For Loops ("C"-style For Loops) and Foreach Loops (List Iteration Loops), but "for[each] $i ( 0 .. 5 )" is neither. It's actually a Counting Loop like FOR ... NEXT in BASIC.