lua-users home
lua-l archive

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


> On Mar 24, 2017, at 7:34 AM, Coda Highland <chighland@gmail.com> wrote:
> 
> On Thu, Mar 23, 2017 at 9:54 PM, Tim Hill <drtimhill@gmail.com> wrote:
>> 
>>> On Mar 23, 2017, at 8:26 AM, 彭 书呆 <nerditation@outlook.com> wrote:
>>> 
>>> 
>>> ... so I have to use full userdata, then store the pointer itself into the full userdata.
>>> 
>> 
>> Isn’t that really the point here? For some reason you don’t want to create a full userdata to wrap a void* to some externally managed C struct? Why not?
>> 
> 
> The "why not" was already explained: that means that you can have two
> Lua objects pointing to the same C object, but the Lua objects compare
> as unequal.
> 
> /s/ Adam
> 

Not if you have __eq in the metatable. And in any case this only happens if your C code actually creates more than one full userdata for a given C pointer, something that is in the control of the coder (it’s easy to use a weak table in the registry to lookup a full userdata by the encapsulated void* light userdata).

—Tim