[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Empty? No. Array? No. Has? Yes.
- From: Andrew Starks <andrew.starks@...>
- Date: Wed, 3 Jul 2013 11:58:07 -0500
I replied to a different thread (too much splitting). To keep things
together, I will cross-post:
I'd suggest not having `nothing`.
a = function() end
b = function() return end
c = function() return nil end
print(select('#', a()), select('#', b()), select('#', c())
--> 0, 0, 1
exists(...)
return not select('#', ...) == 0
end
local foo
print(exists(foo))
-->true
print(exists(baz))
--false --currently true
print(exists(a()))
--false --currently true
print(exists(b()))
--false --currently true
print(exists(c()))
--true
This is not to suggest an implementation. It is only to illustrate behavior.
-Andrew
On Wed, Jul 3, 2013 at 11:29 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>> What people seem to be asking for is:
>>
>> Platonic essence Lua NeoLua
>> nothing nil empty [1]
>> nil nil nil
>
> How do you distinguish between these two cases?
>
> x = function() end
> y = function() return nothing end
>
> -- Roberto
>