Axel Rauschmayer wrote:
I am not saying that the transition from the old rules to the new rules will be 
entirely painless, but if the new rules are simple, that pain is worth it, IMHO.

There are no new rules. Some functions ignore |this| or bind it rather than using it. These differences in kind do not change due to arrows.

  Library code might need to go to extra lengths to help normal developers with 
the transition (error messages, different behavior, tool functions, etc.) and – 
to be explicit – might need a predicate such as `isArrowFunction` (which should 
only ever be used under the hood and thus would not increase confusion for 
library*users*).

There's no point in such a misnamed predicate. Today we have functions that ignore or bind |this|, as well as those that use |this| passed by the caller. Code requires and assumes one kind or another and does not test (and most programmers wouldn't cover all cases, and shouldn't have to).

Part of an API, an essential part of the contract, is any function parameter's |this| binding. Arrows make it easier to use callbacks wanting lexical |this| or not using |this| at all. This covers a large cohort. Code invoking the arrow is not going to test well or at all and do something helpful, or unhelpful such as throwing an exception.

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

Reply via email to