lua-users home
lua-l archive

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

Hello all,

I've been following the "problems with nil" thread here with great

It seems as if there are two major problems with the various uses of nil
in Lua: its use in place of a boolean false value, and its use to
represent table members that are not there. Adding a false (and possibly a
true) value to the set of values directly supported by lua would fix only
the first problem.

There is a similar, though somewhat less sever, problem in Smalltalk.
There are times when it is important to differentiate between a variable
that contains a default value and one that contains no value at all. The
solution in Smalltalk/V was to add an EmptySlot class and associated

It may be worthwhile to consider this as a possible solution to the
problem of using nil to show empty slots. This requires some thought:
while adding a new false value and type is a relatively small change to
Lua, splitting nil's use as a default value and empty slot value would
break a lot of code. Maybe someone with more Lua experience can come up
with a way that fits the language better.

  - Tom Wrensch