|
Am 02.12.2013 07:01 schröbte Sean Conner:
It was thus said that the Great Sir Pogsalot once stated:I am saying that it is out of my control, as it is done by code I did not write. So the metatable check works but the subsequent rawlen() fails.That's what I'm not understanding---the call to lua_rawlen(). To me, it sounds like a defensive programmer going overboard. Personally, I don't believe in defensive programming as it hides bugs [1]. Trust the programmer; do NOT trust the outside world though.
... and don't trust that two programmers that have never even talked to each other will always produce compatible code.
Consider two C extension modules written by different authors, which use the same name for `luaL_newmetatable` but for different C types. No trust in either programmer will prevent a crash when a user loads both modules.
Maybe `luaL_newmetatable` should raise an error instead of returning `0` if there already is a metatable for a given name in the registry.
-spc (Fail fast)
Philipp (still satisfied with `luaL_checkudata` alone)