lua-users home
lua-l archive

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


On 3/16/2018 4:16 AM, albertmcchan wrote:
On Mar 15, 2018, at 3:55 PM, Sean Conner wrote:

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:


I had been saying this all along (false = nil in table)

So it's an impedance matching issue between programming languages and we're adding more duct tape? :-p


Quote from Evolution of Lua, sec 6.1: https://www.lua.org/doc/hopl.pdf

For a long time we resisted introducing boolean values in Lua: nil was false and anything else was true. This state of affairs was simple and seemed sufficient for our purposes. However, nil was also used for absent fields in tables and for undefined variables. In some applications, it is important to allow table fields to be marked as false but still be seen as present; an explicit false value can be used for this. In Lua 5.0 we finally introduced boolean values true and false. Nil is still treated as false.


--
Cheers,
Kein-Hong Man (esq.)
Selangor, Malaysia