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:
-
Bool
will considerfalse
,null
,undefined
as false, everything else astrue
. -
Demorgan
will considerfalse
,null
,undefined
,0
as false, everything else astrue
.
But since there are many languages with different implementations and considerations about what 0
means, an idea is:
Bool
will considerfalse
whatever the language already considersfalse
.Demorgan
will considerfalse
everything the language already considersfalse
, except0
which 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)