lua-users home
lua-l archive

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

On Wed, Jun 11, 2014 at 7:43 PM, Kalafut, Bennett <> wrote:

>    Inspection of the ltablib.c confirms that this isn't just a problem with the embedded Lua we're using: the official code uses lua_rawgeti for array access and doesn't fall back on the metamethod at all. 

One thing that's often bugged me in Lua is the imbalance between table access methods:

if I want to look up a string, I can use lua_getfield() as a shortcut, instead of lua_pushstring() and lua_gettable().
If I want to look up an integer, I can use lua_rawgeti().
but, one of these invokes metamethods, and one doesn't. Why is that? I keep missing a "lua_geti()" that retrieves an integer and does invoke metamethods. (and then there ought to be a lua_rawgetfield() for consistency.)

Sent from my Game Boy.