arrows and a proposed softCall
anguscroll at gmail.com
Sun Jun 3 05:05:10 PDT 2012
On Jun 2, 2012, at 23:14, Brendan Eich <brendan at mozilla.org> wrote:
> Angus Croll wrote:
>> To my mind (2) is the actual problem. To quote Yehuda "the proposed semantics interfere with more intentional uses of `call` and `apply`."
> Users of call and apply who need to override |this| have as their contract that any funarg they take has dynamic |this|.
Yes of course, can't argue with that logic, or your earlier explanation of why modern engines can't be expected to have call/apply modify a hard binding.
But that's exactly why we should be conservative about locking users into hard bindings when their intentions are not clear (clear: 'bind' or no |this| value, unclear: arrow functions). As someone who views call/apply as cornerstones of the language and who's libraries depend on it, an unintended hard binding is a needlessly broken utility. But I repeat myself.
> So are you looking for an isBound predicate just to throw an error? I'm not saying that is a non-goal, I'm just asking to find out if there's some other, non-throwing recourse your code could use.
I'm not looking for an isBpund predicate - not sure the dividends would be worth the effort. If the hard-binding is non-negotiable then it would be more useful (and instructive for the user) for call/apply to tell me why it won't change my context - I'd rather it throw an error* than have our utils silently fail because the user was unaware of the semantics of =>.
*If the intention is to use call/apply purely as an argument passer this can be indicated by a null context argument which would suppress the error
More information about the es-discuss