lua-users home
lua-l archive

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


Pierre-Yves Gérardy wrote:
Following the floating point discussion, I tried to look for a compilation of the various gotchas Lua beginners encounter, but I couldn't find one, so I decided to compile one...


Very commendable initiative! :-)

If these could be considered gotchas:

1. I discovered "late in the game" that the most efficient way to append an item to an array was
a[#a+1]=item
and not
table.insert(a,item)


2. (this is more on the "someone tell me the rationale" side)
I was really puzzled that no library copy operation existed (ie. table.copy). After all the only data structure in Lua are tables, and making shallow or deep copies of them is not something one should consider an infrequent operation. Only after a while I began to understand the minimalistic "philosophy" of Lua.