[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal: fallback of __tostring uses __name
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 10 Nov 2016 13:59:37 -0200
> 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;
Small bug: if __name is defined but it is not a string, its value
won't be popped.
-- Roberto