[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: __methcall
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 04 Nov 2004 16:56:28 -0200
> 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.