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

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


Brendan Eich wrote:
> Allen Wirfs-Brock wrote:
>> I still stand by my alternative semantics as being a way to address 
>> the more important use case without have ?()
> No, the basis cases differ and that is a bug in your alternative.
>
> foo?.bar means take bar from foo or undefined if foo == null.
>
> foo?.bar() means take bar from foo and throw if foo == null else try 
> to invoke the result if typeof "function", else undefined.
>
> This is an off-by-one bug.

It also uses ?. to mean . and magically applies the ? to the later ().

Or if the semantics suppresses a TypeError both for the "take bar" and 
"invoke it" parts, then it's mixing two things in one under syntax 
located in the wrong place for the second suppression. Mainly, 
suppression should be precise and at the point of application -- where 
the dot goes if getting or setting, where the left paren goes if invoking.

Also, if you agree that the ?( case in CS is less significant, then we 
shouldn't add it in haste or mangle ?. semantics to try to cover it.

/be


More information about the es-discuss mailing list