lua-users home
lua-l archive

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


> P.S. Is there a particular rationale in the Lua C API for which things
> return a boolean and which things simply leave nil on top of the stack?
> lua_gettable leaves nil. lua_getmetatable returns a boolean.

lua_gettable leaves nil because that is the result of accessing an
absent field. However, the result of accessing the metatable of an
object with no metatable is not nil (otherwise we could index nil to get
the metamethod). From a pragmatic point of view, almost always you
take different actions acording to whether an object has or not a
metatable. This is not the case for gettable.

-- Roberto