lua-users home
lua-l archive

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


> hi, I'm migrating my project(yet another binder) from lua 5.0.2 to 5.1.1. and
> noted that the function: luaL_newmetatable(luaxlib.c) is not a dual mapping any
> more - in 5.1.1 it only map name to metatable.
> 
> Is there some other function can do the dual mapping? or 5.1.1 just dropped this
> feature?
> 
> Thanks.
> 
> p.s. in PIL 1ed, 28.2: "The luaL_newmetatable function creates a new
> table (to be used as a metatable), leaves the new table in the top
> of the stack, and associates the table and the given name in the
> registry. It does a dual association: It uses the name as a key to
> the table and the table as a key to the name. (This dual association
> allows faster implementations for the other two functions.) "
>

The book overspecified that function. The mapping from the metatable to
the name was an internal "detail" to optimize luaL_checkudata. Lua 5.1
implements luaL_checkudata differently, and therefore does not need that
mapping. Of course, you can do the dual mapping if you need it, using
the usual table-manipulation primitives.

-- Roberto