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 Roberto Ierusalimschy once stated:
> 
> Many years ago, we added booleans to the language exactly because we    
> could not store nil in tables. 'false' is just a 'nil' that we can store
> in tables. ('true' is useless in Lua.) If tables could store nils, the
> language would not need 'false'.                                  

  I've been using Lua since late 2009, and this is the first time I even
*heard* of this.  Why did you not bring this up the previous n-times that
the issue of holes came up?  Is there some sort of FAQ we can add this to? 
Like:

	3.1415926 Why can I not store nil in arrays?

	Answer:  Because.  If you need to store a nil in an array, use
		false.  It was created for just this purpose.

  Also, if this is the case, then why doesn't table.pack() replace nil with
false?  Then you could get rid of the t.n hack, given that false was
intended to be a storable nil in tables.

  For the record, I'm happy Lua has true and false.  I use them all the time
although not for the intended purpose of storing nils and not-nils in
arrays.

> I don't think people understand the point about compatibility.
> 
> The new semantics is NOT COMPATIBLE with the old one. We know that. That
> is why we are NOT TURNING THIS NEW SEMANTICS AS THE DEFAULT in Lua 5.4.
> LUA 5.4 WILL BEHAVE EXACTLY AS LUA 5.3 REGARDING ASSIGNMENT OF NILS
> TO TABLES.

  You might need to reconsider things if you are resorting to ALL CAPS to
make your point.  Maybe a REAL array implemention?

  -spc