[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Install __newindex for _G in C
- From: Sean Conner <sean@...>
- Date: Thu, 14 Oct 2021 19:42:23 -0400
It was thus said that the Great Jonathan Goble once stated:
>
> There are definitely some things in the C API that could be named better,
> agreed. This is a prime example. luaL_setmetatable is rarely used though, I
> would guess, as for its intended purpose, luaL_newmetatable is usually
> simpler.
I'm not following your logic here. luaL_newmetatable() will register the
table on the top of the Lua stack in the Lua registry with the given name.
luaL_setmetatable() will retrieve this table from the registry and assign it
to the object at the top of the Lua stack.
-spc