On 25-Jan-07, at 11:22 AM, Jimmie Houchin wrote:
Okay, I learned that '000' is not a valid name in Lua.
But for whatever reason it is accepted successfully as a table index.
I don't if that is something I can depend on or not.
Yes, you can.
If I don't care about losing the syntactic sugar of t.000 for access,
are there other inherent problems with using digit strings to index
tables?
No, there aren't. :)
Any Lua object except nil [see note] can be used as a table key. That
includes strings (of any kind, which can include \0), numbers (including
numbers like 0.5), tables and functions.
Names are just a feature of the compiler: once the script is compiled,
there is no difference between a.john and a["john"]. They compile to
the same virtual machine code.
[Note: Technically, there is one other object which cannot be used as a
key: the "not a number" (NaN) value which can results from invalid
mathematical operations like 0/0. That's because, according to
"standard" (IEEE-754) semantics, NaN is not equal to itself.]