lua-users home
lua-l archive

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

2006/11/15, Shmuel Zeigerman <>:

Why isn't there one for user data ? lua_objlen return the block size
of a userdata, whereas #ud in Lua calls the "len" metamethod. Is there
an equivalent of lua_objlen that push its result on the stack and that
calls metamethods on userdata if there is any ?

The only fallback I found was to create a length function in Lua :
length = function(obj)
  return #obj
and to lua_call it from my C code. But I can't figure out how to port
that function to C, there seems to be a missing API function (unless I
emulate the behaviour of the # operator by accessing metatable