[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Feature request: per-value uservalue
- From: 彭 书呆 <nerditation@...>
- Date: Thu, 23 Mar 2017 10:03:16 +0000
在 2017/3/21 2:26, Tim Hill 写道:
>> On Mar 19, 2017, at 8:55 PM, 云风 Cloud Wu <email@example.com <mailto:firstname.lastname@example.org>> wrote:
>> Tim Hill <email@example.com <mailto:firstname.lastname@example.org>>于2017年3月20日周一 上午11:12写道：
> But a light userdata with a metatable basically *IS* a full userdata. The only difference is that the full userdata is allocated by Lua, and undergoes garbage collection .. which you ALSO want for the __gc. As you noted, the technique here is to allocate a full userdata that just holds a C pointer (aka a light userdata).
> Your request won’t get you a lower overhead .. it will just get you something else that is identical to full userdata but with a different name.
one major difference between light- and full- userdata is the equality test.
light userdata is tested by value while full userdata is tested by reference.
this make big difference when you need to use them as table keys.
the nerdy Peng / 书呆彭 /