lua-users home
lua-l archive

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

The idiom of nil meaning false *is* a bit strange (but no stranger than 0
meaning false in C).  Just for my own programming sanity I usually use 1==1
and 1==0 to stand for true and false so that my code makes the assumption
that all the comparison operations return the same thing for true and false
(obviously that may be broken), and I try not to think about what that value

That way a function that needs to return a boolean value will have lines
like 'return 1==1' for returning true.

I've also taken to making the test against nil explicit for existence tests,
as in 
while t[i]~=nil do ... end

For one thing, coding like this is compatible with the introduction of a
boolean type.