BTF Measurements

Aymeric Vitte vitteaymeric at
Fri Mar 16 07:29:06 PDT 2012


I think I have missed something in the discussions (or globally) because 
I don't understand very well why methods are involved in lexical this.

But if it is so, why events handlers should be different from a js 
perspective ? Maybe you could include in the tool everything that is a 
method function expression

Probably it will be more clear once the proposals are updated (or maybe 
I read it in a wrong way but I don't see what happens to methods), and 
the example below illustrated (I have tried to write what it will 
become, probably completely wrong) :

-------------------- Today

var a=function() {var self=this;var c=function() {var a=self;return a}};
var test='essai';
var o={test: 'test'};
o.m = function() {var a=this.test;return a}
a = o.m;
var b=function() {};
     test2: function() {var a=this;return a}
o.m(); //test
a(); //essai

--------------------- Tomorrow

var a=function() {var c=() => this}; (fat arrow)
var a=fn() {var c=() => do {var a=this;return a}; (fn + fat arrow)
var a=fn() {var c= do () this}; (do)
var a=fn() {var c= do () {var a=this;return a}}; (do)

     test2: () => this
... same as above
     test2() {var a=this;return this}

o.m = () => this;
o.m =() => do {var a=this.test;return a};
o.m = do () this;
o.m = do () {var a=this.test;return a};

o.m();//essai ???
a();//essai ???

Le 16/03/2012 14:44, Kevin Smith a écrit :
> Hi Aymeric,
> I'm glad we're on the same page.   I analyzed the code from that site 
> and got the same results as you.  The percentage of BTF candidates is 
> 68% of all function expressions, but the combined BTF candidates and 
> object literal methods are only 78%.
> There are very few object literal methods in this sample, so in order 
> to explain the 78% we're going to have to dig into the "non-method" forms.
> As you point out, event handlers are attached using the following idiom:
>     element.onevent = function() { ...this... };
> Although they are not trivially convertible to BTFs, event handlers as 
> above can generally be refactored like this (using a purely expository 
> BTF syntax):
>     element.onevent = () => { ...element... };
> or even:
>     element.onevent = (evt) => { };
> I think think analysis supports the idea that BTFs are widely applicable.
> kevin

Email :  avitte at
Web :
Webble :
Extract Widget Mobile :
BlimpMe! :

More information about the es-discuss mailing list