[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature request: per-value uservalue
- From: Coda Highland <chighland@...>
- Date: Fri, 24 Mar 2017 10:26:23 -0700
On Fri, Mar 24, 2017 at 7:46 AM, Thomas Jericke <tjericke@indel.ch> wrote:
> On 24.03.2017 15:34, Coda Highland 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
>>
> You can, but you don't have to. To avoid creating two Lua objects pointing
> to the same C objects is also possible with userdata, you just need some
> care.
> --
> Thomas
Well yes, of course, you make a weak-valued table with lightuserdata
keys and full userdata values and marshal your pointers through that,
but it's not immediately obvious and there are a number of possible
pitfalls in the implementation (for example, forgetting that
weak-valued tables are a thing makes this solution either ridiculously
leaky or annoyingly difficult to maintain).
This has come up a number of times before, so while I don't think that
"per-value metatables" is the right solution to the task, it does at
least indicate that the issue is fairly common.
/s/ Adam
- References:
- Feature request: per-value uservalue, Xavier Wang
- Re: Feature request: per-value uservalue, Tim Hill
- Re: Feature request: per-value uservalue, 云风 Cloud Wu
- Re: Feature request: per-value uservalue, Tim Hill
- Re: Feature request: per-value uservalue, 彭 书呆
- Re: Feature request: per-value uservalue, Tim Hill
- Re: Feature request: per-value uservalue, 彭 书呆
- Re: Feature request: per-value uservalue, Tim Hill
- Re: Feature request: per-value uservalue, Coda Highland
- Re: Feature request: per-value uservalue, Thomas Jericke