[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: nil isn't as unique in Lua 4.1
- From: David Jeske <jeske@...>
- Date: Thu, 10 Jan 2002 03:39:05 -0800
On Thu, Jan 10, 2002 at 12:37:35AM -0500, Peter Shook wrote:
> I'd rather not have the boolean type because then there will be a need
> for functions like Perl's 'defined' (to tell if a variable is not nil)
> and 'exists' (to tell if a table has a value for a particular key). How
> else with you be able to tell if a variable is false or nil?
We could introduce a new operator to replace the overloading of
"or". Something like "ond" (On Not Defined):
nil or 2 -> true
nil ond 2 -> 2
false or 2 -> true
false ond 2 -> false
nil or false -> false
nil ond false -> false
This seems better than having to do this all the time:
a= if defined(b) then b else c end
However, don't get me wrong, I'll take any pain required if it means I
can actually store a false value in a table. Currently I have to make
EVERY if statement look like "if expr ~= 0", just so I can store 0
(i.e. false) values in a table.
--
David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net