BTF Measurements

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


Hi,

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() {};
b.prototype={
     test2: function() {var a=this;return a}
}
o.m(); //test
a(); //essai

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

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

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

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

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) => { ...evt.target... };
>
> I think think analysis supports the idea that BTFs are widely applicable.
>
> kevin
>
>

-- 
jCore
Email :  avitte at jcore.fr
Web :    www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com



More information about the es-discuss mailing list