lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


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 [1].  Let's flip this around a
bit.

	function something(mary) --[[ something about mary ]] end

  In straight Lua, there is no way for something to know if it was called
like:

	something()

or

	something(nil)

  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 --[[2]] 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? [3]

  -spc (Or are we all being nihilistic here?)

[1]	Yes, I'm procrastinating at work.  Looking at core files of stripped
	executables will do that to a person.

[2]	Assuming nothing existed in Lua.
  
[3]	Okay, *now* I'm being silly.