On May 30, 2012, at 2:18 PM, Mark S. Miller wrote:
> On Wed, May 30, 2012 at 10:32 AM, Allen Wirfs-Brock <[email protected]>
> wrote:
>
>> ...
>
> However, there might be some utility (at least for debugging) in having a
> Function.prototype.isThisBound method. It would return true for arrow
> functions and functions created via Function.prototype.bind
>
> I agree that such a predicate would be useful, but the useful predicate
> should also give "true" for functions that don't mention "this". Thus,
> "isThisBound" may not be the right name. What it really means is 'Can this
> function sense the "this" binding with which it is called?" If we call it
> "canSenseThis", then clearly we should also reverse the truth value.
Or course, a |this| reference might be obscured, for example:
() => eval(funcThatReturnsThisString()+".propName")
I think we agree that all fat arrow functions and all functions created using
bind have fixed |this| bindings, regardless of whether or not they actually
contain a static reference to |this|
From that perspective I think "isThisBound" or just "isBound" is how most
people will think about it.
If you want to reverse the sense, I think it would be something like
"hasDynamicThis" or perhaps even "isMethod" (where by definition methods would
be functions with dynamic |this| bindings).
"canSenseThis" doesn't do a lot me.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss