|
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... ... Are there other potential traps? On what did you stumble while learning the language?
I just stumbled onto something in the C API that doesn't seem to be documented in the reference manual and caused a bug in my Lua/APR binding (reported a few hours ago on GitHub*):
When you create a new userdata by calling lua_newuserdata() the newly created userdata gets a default environment table installed which turns out to be ... wait for it ... the global `package' table :-|. I don't consider this useful behaviour and I couldn't find any mention of it in the Lua 5.1 reference manual (please correct me if I'm wrong).
From the lua-users wiki** I understand that in the current implementation the environment table must point to somewhere, this might explain the nonsensical default.
- Peter * https://github.com/xolox/lua-apr/issues/#issue/1 ** http://lua-users.org/wiki/UserDataRefinement