Existential operator (was: ||= is much needed?)

Brendan Eich brendan at mozilla.org
Tue Jun 19 10:15:56 PDT 2012


David Bruant wrote:
> What about a more generic operator that would be able to silently 
> absorb any error?
>
>     let greedy = obj.hints?.greedy;
>
> would become:
>
>     let greedy = silent obj.hints.greedy;

Ignoring exact syntax, I don't think we want more general throwing 
suppression. The goal with existential operators is to suppress exactly 
the TypeError thrown when trying to get properties from null or undefined.

Suppressing errors requires care, that's why ?. is not . (the default). 
But even with opt-in, exceptional-circumstances syntax, we should prefer 
a narrower semantics to an over-broad one that will, all else equal, 
tend to hide bugs and fail to express precise programmer intention.

The other point I will make is that we should take the CoffeeScript user 
testing results to heart, moreso than thought experiments. In this light 
I invite all CS users to comment.

/be


More information about the es-discuss mailing list