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

Herby Vojčík herby at mailbox.sk
Tue Jun 19 11:24:21 PDT 2012

Brendan Eich wrote:
> Jeremy Ashkenas wrote:
>> Everywhere else in the language, `?` means existence (not null or
>> undefined) -- but when used to call a function, the check ensures that
>> the value is callable as well. In a DWIM sense, this makes sense,
>> because the only things you'd ever want to try to call in JavaScript
>> must be callable ... but I think it's strange that the meaning of
>> "existence" alters itself just for this use case. I opened a ticket
>> talking about rolling it back to "null or undefined" semantics here:
>> https://github.com/jashkenas/coffee-script/issues/2315
> Apart from people misreading the proposal in this issue, it does seem to
> be removing a bit of utility, but perhaps that's not actually used? Do
> CS users try to ?(-invoke a maybe-function that is sometimes neither
> null nor undefined nor typeof-type "function", but rather something that
> coerces to object?
> The way to get ?( into JS is by a longer spelling:
> options.success?.(response)

Will you include options.success?.[index] then, too?

> Pretty ugly, but it puts the ? magic right where the maybe-test belongs.
> /be


More information about the es-discuss mailing list