lua-users home
lua-l archive

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


2016-03-13 22:05 GMT+02:00 Alloyed <alloyed@tfwno.gf>:

> I don't like the idea that the order of a table literal might matter,
> especially for cases where tables are generated by code.

Lua's table type is so general and versatile that a bit of discipline
in its usage does not come amiss. For most of my tables, I follow
the following rules.

1. The table is a proper sequence (§3.4.7 of the Lua 5.3 manual).
2. The [0] entry, if present, is an index to an arbitrary selection of
keys, usually a string with pieces gmatching "%a%w*" but
sometimes just a list of values.
3. I seldom use 'pairs'.