Existential Operator / Null Propagation Operator

Brendan Eich brendan at mozilla.org
Tue Apr 7 17:50:37 UTC 2015

Christoph Pojer wrote:
> it doesn't have to be a bug. It asserts that if a is not
> null/undefined, it must have a property b. This can be enforced
> through static typing.

What do you mean? JS does not have static typing. Even if it got it via 
SoundScript, the new mode would be an opt-in. The default and vast 
majority of JS, which might like to use ?. (or whatever the syntax 
should be), could not rely on types.

Kevin's suggestion is that we solve the non-compositional 
CoffeeScript-like translation problem by converting null-ish (null or 
undefined) left operand of ?. (I'll use that syntax for now as it is 
familiar) to the Nil (h/t bbenvie) value proxy, which soaks up further 
property accesses by returning itself, and soaks up calls too.

As a sketch of semantics, this seems promising (no appeal to static 
typing) but I'm low on caffeine at the moment. What am I missing?


More information about the es-discuss mailing list