lua-users home
lua-l archive

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

On Thu, Oct 14, 2021 at 7:42 PM Sean Conner <> wrote:
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.

Sigh. My brain is a bit fried from school assignments and a cold that set in a couple of days ago, so I'm not totally thinking straight. Thanks for the correction (it's been some time since I used these functions).