On Tue, Mar 13, 2012 at 9:25 AM, Kevin Smith <[email protected]> wrote:
>> I'm confused by this paragraph. Functions that benefit from 'this'
>> binding would reference 'this' or an alias for 'this' right?
>
>
> In this analysis, functions that reference an "alias" to this (e.g. var self
> = this) within an inner scope are counted:
>
> (function() {
> var self = this;
> (function() { console.log(self); });
> });
>
> This results in 1 BTF candidate (the inner function).
Then does it count this:
(function() {
var self = this;
(function() { console.log("foo"); });
});
?
Can you answer the 'cost' side of the BTF issue? That is if BTF was
really easy, how many times would we have to opt-out so we can use the
default value of "this"? My guess: you will need a lot zeros in place
of X in 0.0X% ;-)
Sometimes the 'this' is not needed at all; does it ever matter that it
is set to the lexical this?
>
> In my analysis, I mention that this methodology will tend to undercount the
> BTF candidates, because functions with explicitly bound "this" (through
> Function.prototype.bind or other means) will tend to get marked as
> "methods":
>
> element.onclick = function() {
> console.log(this);
> }.bind(this);
Well FWIW I stop using "var self" the day bind() landed.
jjb
>
> The analyzer reports 0 BTF candidates, even though we clearly should have 1.
> Since the tool undercounts, we can say that the reported numbers offer a
> lower bound on BTF candidacy. The fact that BFT candidacy may be higher
> doesn't alter the analysis.
>
> kevin
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss