Re:Lua: Good, bad, and ugly parts
by Fargren on Saturday March 09, 2013 @02:53PM
(#5349403)
Correct me if I'm wrong, but what's inconsistent there is not boolean evaluation, it's number to boolean conversion. 1 == true and 0 == false are pretty standard, but that doesn't mean 0 and 1 are booleans.
[ Parent
| on HN ]
Only nil and false evaluate to false. Because there's no distinction between nil and non-existent elements, checking the existence of an element with a value of 0 requires that 0 evaluates to true, so you get this situation:
while 0 do print("loops forever") end
while not 0 do print("does nothing") end