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 thatthe 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)
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.
|