[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Lua 5.1 (work6) now available (for loop)
- From: "Joshua Jensen" <jjensen@...>
- Date: Thu, 19 May 2005 10:40:10 -0600
> > Perhaps I can do a better job explaining if I actually
> understood why
> > adding the extra (ugly) syntax for basic table iterations
> makes Lua a
> > better language.
> As Myke pointed out, this is an old decision. The rationale
> is that we do not see "pairs" as the "basic table iteration".
> I, for instance, use ipairs much more frequently than pairs.
> I believe that is true for many other programmers.
I just did a search of all our Lua scripts. There are hundreds and hundreds
(nearing 1,000) of occurrences of the basic:
for key, value in table do
We do a lot of data manipulation, and the Lua 5.0 default is very
reasonable. It also keeps the syntax simple and mirrors more closely the
simple syntax of, say, Python for doing the same thing (a battle I
It's really going to be a lot of grunt work to change every single one of
those 'for' statements. Is there a reasonable workaround to catch all of
them and assign them back to the previously quite usable default of pairs?
And after checking the manual again, it seems to me that ipairs would be the
same as pairs on a table consisting purely of array entries. Is that true,
or am I missing something?