[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Proposal: fallback of __tostring uses __name
- From: Daurnimator <quae@...>
- Date: Fri, 11 Nov 2016 02:05:55 +1100
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;