lua-users home
lua-l archive

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


At the moment the code in `luaL_tolstring` is:

    default:
      lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
lua_topointer(L, idx));
      break;

Instead of `luaL_typename`, it would be nice to use __name.
(questionable untested code ahead):

    default:
      if (luaL_getmetafield(L, idx, "__name") == LUA_TSTRING) {
        lua_pushfstring(L, "%s: %p", lua_tostring(L, -1),
lua_topointer(L, idx));
        lua_remove(L, lua_absindex(L, -2));
      } else {
        lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
lua_topointer(L, idx));
      }
      break;