Open ElizabethHudnott opened 9 years ago
Some follow up experiments...
In tkeden @ || 1 is @, whereas in JavaScript and JS-EDEN @ || 1 is 1 and @ || true is true. I think JavaScript has the correct semantics here. If the right hand side is true then it doesn't matter whether the unknown value on the left hand side is true or false, in two-valued logic the result would be true either way. This is the semantics of NULL OR TRUE in SQL, whereas tkeden is just plain weird.
Similarly, false and @ being @ seems weird too. Whoever made that decision, it is an independent decision to the lazy/eager distinction. Both sides need to be evaluated for an eager operator but I'm not sure why the result should necessarily be different.
However, the fact that our and and or are currently lazy (and therefore just synonyms of && and ||) when they should be eager does need fixing. The truth table for && in JS-EDEN matches tkeden, though @ && false evaluating to @ seems suspicious to me.
Also not @ should be @ rather than true. !@ currently evaluates to true, which is correct. not is a three-valued logic inversion, whereas ! is a pessimistic (or "closed world") reduction to two-valued logic (as in unknowns are assumed to be false). It is possible to define optimistic, pessimistic and three-valued versions of each of conjunction, disjunction and negation and each version of conjunction and disjunction can additionally be eager or lazy, so in total 15 possible versions proliferated from three Boolean operators(!!) make some sort of sense to me, plus the @ && false equals @ variation that JavaScript, tkeden and JS-EDEN use, which doesn't make sense to me but if we can get away without needing to have an emulation layer for && then the performance would be better to stick with what JavaScript provides.
Some valid points, still unresolved. However, false and x++
is a syntax error currently since we don't allow mixing expressions and statement like that atm.
Eagerness: x = 0; writeln(false and x++); writeln(x);
x should have the value 1, not 0.
Truth values with @:
writeln(false and @);
Result should be @, not false.
Reference: http://www.dcs.warwick.ac.uk/research/modelling/other/eden/guide/operators/logical.html