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

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Jun 19 12:33:21 PDT 2012

On Jun 19, 2012, at 12:26 PM, Brendan Eich wrote:

> Brendan Eich wrote:
>> Worse, instead of leaking an observable ConditionalReference (whew!), you've opted to break the equivalence between foo.bar() and %tmp = foo.bar; %tmp.call(foo) for the case where . is replaced by ?. -- in this case your proposal does not throw while the expansion does.
>> The right extension for what CoffeeScript calls ?( is simply to use an unambiguous and backward-compatible extension, such as ?.( instead. 
> Jeremy pointed out privately that the need for ?( is less acute in practice, and also because of .call via the equivalences:
>  foo.bar?(args) <==>  foo.bar?.call(foo, args)
>  fun?(args) <==>  fun?.call(undefined, args)

How are these equivalent? Won't  fun?.call evaluate to undefined if fun is undefined and undefined(undefined,args) will throw...


> But ?.( is shorter. It's awkward to use three chars instead of CoffeeScript's two, and to have a dot in the middle where no get or set is implied.
> /be
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

More information about the es-discuss mailing list