lua-users home
lua-l archive

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


On 21.03.2018 00:30, Hisham wrote:
On 20 March 2018 at 18:38, Sean Conner <sean@conman.org> wrote:
It was thus said that the Great Dibyendu Majumdar once stated:
On 19 March 2018 at 17:51, Dirk Laurie <dirk.laurie@gmail.com> wrote:
Lua 5.4 should have a constant of type nil called 'null' [1]. Not a
new keyword, only a new predefined value.

All the functionality aimed for with nil-in-tables can be achieved this way.

- Being of type nil, 'null' by itself tests false.
- Not being equal to nil, 'nil' is a non-hole.
- Can be preassigned to global values (or a value in any table) so
that __index can just signal an error.

Hi, I agree partly with your idea. Maybe Lua can have a well defined
singleton object call MISSING or NONE or UNDEFINED. Say it is a global
value which is actually just a Userdata.
  Um ... Roberto just said that "false" was introduced into Lua *just for
this purpose*.
Which, with all due respect I obviously have towards Roberto, I think
it's a very odd choice and the wrong motivation for booleans. As a Lua
programmer, I love having first-class booleans in the language, but it
would never occur to me to use "false" them to represent "missing
value" -- false means false. And true is not useless in Lua, it means
true, and allows us to state our intent in an unambiguous and
interoperable way. 
Couldn't agree more. False is to me a way to explicitly say "this value is not missing it is untrue" while nil is a missing/undefined value.
And following the discussion here, it seems that false didn't solve the storing nil into a table problem after all.
Either because it was not the right value for the job or because no value could fill that job. I am tending to the first answer.
--
Thomas