lua-users home
lua-l archive

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


Hi all,

Is there any guarantee that for any list with a list part,
the list part is enumerated first by pairs()?

Another way to put it: does pairs() always enumerate first what would be
enumerated by ipairs(), then the rest of the table?

eg.  with  t = {a=88, 11, 22, 33, b=99},
is there any guarantee that pairs will return first (1, 11),
(2, 22), (3, 33), then the rest of (key, values) in an arbitrary order?

[ Context: writing a hopefully fast and space-efficient serialization
function where the list part of a table can be encoded as a sequence
of encoded values and other table elements are encoded as (key, value)
pairs. ]

I think I remember this being already addressed here. I searched the
mailing list archives but got lost in a sea of "Nil in tables" messages.

TIA

Phil