lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> In fact, it might have been better to define the iterator syntax like this:
>      for p = next,t,nil do ... end
> which looks like the numeric for loop. If the first expression is a 
> number, you would use numeric iteration. If it is a function, you would 
> use iterators.

The whole point of having two different forms for "for" is to be able to
generate good code in both cases, specially in the numeric "for". If the
syntax was the same, the checks would be needed at run time and it wouldn't
be possible to have special VM instructions for each "for" variant.