[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: metatables and == nil
- From: Duane Leslie <parakleta@...>
- Date: Fri, 30 Jun 2017 09:24:06 +1000
> On 30 Jun 2017, at 02:51, ThePhD <jm3689@columbia.edu> wrote:
>
> This prevents me from doing "some_userdata == nil" and having it return true in the case of working with something like a nullptr. I want to keep the ease-of-use/"C-like" style of comparing against Nil, but I cannot invoke a metamethod to check. Does anyone have any suggestions? I'm open to just about anything, and obviously the more elegant/syntax-clean suggestion the better.
I needed the same, and so I run a modified version of the equality test function, attached. If you control the Lua interpreter you can always tweak it, you just need to be careful to vet any third party packages you use to make sure that your modified behaviour doesn't confuse it.
Regards,
Duane.
Attachment:
luaV_equalobj.c
Description: Binary data