On Sun, Feb 22, 2009 at 2:03 PM, Duncan Cross <email@example.com>
On Sun, Feb 22, 2009 at 12:34 PM, David Given <firstname.lastname@example.org>
identical semantics to Lua? Well, unfortunately that's not the case. I'm
use of some of these semantics and I'm not sure how to emulate them.
There's two so far that are biting me:
with numbers, so (0 > null) is valid (and false)
assert(value == undefined)
assert(!((value < 0) || (value > 0) || (value == 0)))
As far as I know there's very little you can do about this except wrap every "if" condition and "and"/"or" operand in a call to this:
local function jstrue(n) return (n and n ~= 0); end
...ugly - and will also break if you want (a || b) to return zero when a is false and b is zero, as the conversion (jstrue(a) or jstrue(b)) will evaluate to false.
I'm sorry about this bit, I skimmed over what you said and responded in non-sequitur, talking about 0 evaluating to nil/false rather than the other way around. That's an even bigger problem - you cannot override the comparison of two distinct Lua data types, so even giving boolean and nil custom metamethods won't help.