lua-users home
lua-l archive

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


>>>>> "bil" == bil til <biltil52@gmail.com> writes:

 Luiz> If you use luaL_setmetatable,
 
 >> FWIW, I never do this and never advise others to do so, because the
 >> fact that luaL_setmetatable relies on string keys means it does not
 >> give any guarantee of uniqueness and relies entirely on module
 >> authors to choose non-conflicting names.

 bil> Can you give some more elobarated example, how this might happen,
 bil> that string keys would clash?

Two different modules written by different people might choose to use
the same name. Then everything explodes if both modules are loaded into
the same interpreter.

 bil> (you mean e. g., that a Lua user program could define some global
 bil> variable with such a metatable string name, and then bad things
 bil> might happen?)

No. Nothing that can be done in Lua code without using the debug library
can cause conflicts here, because we're talking about string keys in the
registry, which is not visible to Lua code except via debug.getregistry().

-- 
Andrew.