This repository was archived by the owner on Nov 3, 2021. It is now read-only.
This repository was archived by the owner on Nov 3, 2021. It is now read-only.
wasm null should be mapped to JS undefined, not JS null #9
Closed
Description
As in any interlanguage mapping, no mapping is perfect but some are more useful than others.
NOTE: It may already be too late to make this change, even if we agree it would have been a good idea.
Wasm null is used for the uninitialized value on of values of nullable types. For nullable types, null will be the unique platform supported value to indicate that the expected value is absent. This corresponds most closely to the JS undefined
rather than the JS null
. For the ES specification itself, undefined
is consistently treated as the indicator of absence:
var x; // x === undefined
let y; // y === undefined
function foo(x) { console.log(x); }
foo(); // unbound parameters bound to undefined
foo(); // non-return returns undefined
({}).z; // absent properties read as undefined
function bar(x = 3) { return x; }
bar(); // 3. unbound parameters use default value
bar(undefined); // 3. parameters bound to undefined act as if unbound
bar(null); // null. null does not emulate unbound
(new Map()).get("x"); // undefined indicates absence