lua-users home
lua-l archive

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


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