lua-users home
lua-l archive

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

19.02.2016, 13:04, "Luiz Henrique de Figueiredo" <>:
>>  Under Lua 5.3.2 with Luiz's complex, I get:
>>  >,1); pairs(z)
>>  stdin:1: bad argument #1 to 'pairs' (table expected, got complex number)
>>  So I can't reproduce your result.
>>  The manual says only:
>>      The entry __name is used by some error-reporting functions.
> __name support was introduced in Lua 5.3: luaL_newmetatable sets it,
> which automatically gives all libraries nicer error messages.
> The OP is using Lua 5.1.

My last message about problem with (<) operator is realted to 5.3. Here is part 5.3's code:

l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
  const char *t1 = objtypename(p1);
  const char *t2 = objtypename(p2);

  if (t1 == t2)
    luaG_runerror(L, "attempt to compare two %s values", t1);
    luaG_runerror(L, "attempt to compare %s with %s", t1, t2);

So, objtypename() is used to get name of type:

#define ttypename(x)	luaT_typenames_[(x) + 1]
#define objtypename(x)	ttypename(ttnov(x))

As one can see, __name is not used at all for this messages.