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)

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

/be

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to