lua-users home
lua-l archive

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


Tim Hill <drtimhill@gmail.com>于2017年3月25日周六 上午4:08写道:

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).

If the void * light userdata is the part of another full userdata,  encapsulating is not a easy job. For example, if we encapsulates a C/C++ object into a full userdata, and then we need to encapsulates a sub-object of it. We should associate two userdatas in lua somewhere to indicate the one is actually the part of another.

In my origin post I suggest add an user tag in the value of a full userdata. So that we can present different part of the same full userdata.