[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: A little bit about nothing (was Re: Empty? No. Array? No. Has? Yes.)
- From: Andrew Starks <andrew.starks@...>
- Date: Wed, 3 Jul 2013 11:52:52 -0500
I don't think that `nothing` should exist as an entity.
The barrier to understanding is that variable assignment == variable
creation and there is no *real* variable deletion at all. We pretend
things are deleted by reading `nil` and this *mostly* works. Lua tells
us `nil` when we ask for the value of something that never existed. So
*mostly*, setting something that does exist to `nil` is
So forget `nothing`.
a = function() end
b = function() return end
c = function() return nil end
print(select('#', a()), select('#', b()), select('#', c())
--> 0, 0, 1
On Wed, Jul 3, 2013 at 11:20 AM, Sean Conner <firstname.lastname@example.org> wrote:
> It was thus said that the Great Sean Conner once stated:
>> It was thus said that the Great Roberto Ierusalimschy once stated:
>> > > Well, I cannot speak for a 'community of best practice' but this is how I
>> > > see the problem. Lua does not have null, as understood in other languages.
>> > I think it does: it is called 'nil'. What Lua does not have is a way to
>> > store 'nil' in a table.
>> There are two concepts here, reflected in the following code:
>> x = function() end
>> y = function() return nil end
> Some further observations on this topic . Let's flip this around a
> function something(mary) --[[ something about mary ]] end
> In straight Lua, there is no way for something to know if it was called
> In other words, was something given nothing? If something was written in
> C, then yes, something can make the distinction between nothing and nil, but
> in Lua, not so much (which is why type can error out with "type()" but not
> with "type(nil)").
> What does the following mean?
> a = function() end
> b = function() return nothing --[] end
> c = function() return nil end
> Should nothing only exist in the context of a table entry? Did the
> previous question even have meaning in the context of language? How can
> nothing exist, context or no? 
> -spc (Or are we all being nihilistic here?)
>  Yes, I'm procrastinating at work. Looking at core files of stripped
> executables will do that to a person.
>  Assuming nothing existed in Lua.
>  Okay, *now* I'm being silly.