This conversation in Wren issues made me search for an alternative naming for Bools that considers 0 as false.
In JavaScript 0 is false.
(() => {
const zero = Boolean(0);
// false
console.log(zero);
})();
In other languages like Wren, 0 is considered as true.
var zero = 0
if (zero) {
System.print("zero is true")
}
So as a way of standarizing, one idea is using the Demorgan value as an alternative naming for Bools.
In a dream world all languages:
-
Boolwill considerfalse,null,undefinedas false, everything else astrue. -
Demorganwill considerfalse,null,undefined,0as false, everything else astrue.
But since there are many languages with different implementations and considerations about what 0 means, an idea is:
Boolwill considerfalsewhatever the language already considersfalse.Demorganwill considerfalseeverything the language already considersfalse, except0which boolean value would be negated.
So in the JavaScript example:
(() => {
const zero = Boolean(0);
// false
console.log(zero);
const negatedZero = Demorgan(0);
// true
console.log(negatedZero);
})();
Top comments (0)