[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Ask userdata type from Lua
- From: Andrew Gierth <andrew@...>
- Date: Sat, 01 Jul 2023 23:27:32 +0100
>>>>> "Luiz" == Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:
>> Or should I best present a "tostring metafunction" for each of my
>> userdata, which is programmed similar to f_tostring in liolib.c,
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.
I always use my own equivalents for luaL_setmetatable and
luaL_checkudata that work off lightuserdata keys instead.
--
Andrew.