[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Why can't I do for...in on a table?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 12 Sep 2005 15:53:08 -0300
> 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.
--lhf