[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [LuaJIT ffi] Misleading error message?
- From: Duncan Cross <duncan.cross@...>
- Date: Sun, 31 Jul 2011 17:43:23 +0100
On Sun, Jul 31, 2011 at 4:55 PM, Justin Cormack
<justin@specialbusservice.com> wrote:
> On Sat, 2011-07-30 at 16:04 +0100, Thomas Lauer wrote:
>> Well, I still think that allowing to compare any value (including ffi
>> values) against the special case of nil would be a sensible thing to do.
>>
>> I imagine you won't go there so perhaps a hint in the ffi docs (if and
>> when you find the time) might be a good idea.
>>
>> > If you really, really need to find out whether something is a nil
>> > object without ever raising errors, then use 'type(v) == "nil"'.
>>
>> That's what I've done as a workaround.
>>
>
> Usually you can just test with 'if not v then ...' rather than if v ==
> nil then ...', so actually comparing to nil is rarely needed, unless
> false is a sane value...
Ah, but with LuaJIT FFI, null pointer values are considered equal to
nil, but are *not* logically false:
> ffi = require 'ffi'
> null = ffi.new('void*')
> print(null == nil)
true
> print(not null)
false
-Duncan