lua-users home
lua-l archive

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

On Mon, Jan 10, 2011 at 11:46 PM, David Manura <> wrote:
> Traditionally, lightuserdata has been intended as a way to represent C
> pointers (or even handles [2]) in Lua, often as keys in a Lua table [1]

FWIW, one inconsistency between the manual [1] and implementation is
that the __eq metamethod is ignored on lightuserdata:

  > mt = {__eq = function() print 'eq' end, __lt = function() print 'lt' end}
  > debug.setmetatable(123u, mt)
  > =123u == 124u, 123u < 124u
  false, true

See luaV_equalval: case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); .

The same can also be said concerning boolean:

  > debug.setmetatable(true, mt)
  > =false == true

Also, the "type" function referred to in the manual's pseudocode is a
form of type() that differentiates between LUA_TUSERDATA and