lua-users home
lua-l archive

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


>
> Here's is my personal take on this: nil *is* a first-class value because
> it can be stored in variables and tables and it can be passed to and
> returned from functions. In all these contexts, nil means "nothing": for
> instance, when you set var=nil, then var contains nothing, as you can
> check when you read var.
>
> The only restriction is that nil cannot be a table *key*, because you
> cannot put something in a "nothing" box or position. This is consistent
> with t[nil] being nil on reads because "nothing" is at nowhere.

What "first-class" exactly means is based on opinion rather than there
be a strict norm.
But nil isn't really first-class, because it cannot really be stored
as value into tables. "storing" it in a table makes the key go away an
not show up on i/pairs, nor can you differ if a table key "stores" a
nil, or is not present.
First class nils would be able to returned by iterators that not mark
the end of iterator.

If that all would be possible, then I'd call it a first-class nil.