Forget this below, sorry I got confused, coming back to your first email
your tool does count function expressions that do not have "this" in
their immediate scope, so indeed functions that potentially need the
literal "this", then you add object literal methods, then this leaves
10% function that can keep the old syntax or get a new shorter syntax
that does not bind "this"
OK, then I have tried again the tool on an ajax app
(http://www.blimpme.com/mobile), the total BTF candidates drops to 77.6 %
I think it is due to the fact that :
var x=document.createElement('div');
x.onmousedown=function() {var a=this.style};
var y=function() {var a=this;};
x.onmouseover=y;
are not counted as BTF candidates
Since I have not yet understood what should become methods with the
arrow/do or do proposals, I can not say more...
Le 14/03/2012 22:15, Aymeric Vitte a écrit :
So BTF stands for "bound-this function expressions"
But it does include case b (don't care about "this")
Then in the next email you conclude :
"Interestingly, when we take the sum of BTF candidates and object
literal methods, we account for over 90% of function expressions."
Is it surprising ?
"This suggests that an additional short function syntax that does
*not* bind 'this' may not be necessary."
??? Why because except object literal methods (+/-50% for which the
lexical this is not supposed to be needed) most of the functions are
the b case ?
I should be missing something important... don't understand exactly
what the analysis does highlight, thanks if you can explain
Le 14/03/2012 13:46, Kevin Smith a écrit :
As far as I have understood "Total Function Expressions" is
supposed to return all functions that do not contain "this" in
their initial scope and that have a "var self=this" trick that is
used somewhere inside the function (ie function() {var
self=this;var b=function() {console.log('test')} is not a BTF
candidate because self is not used), correct ?
Sorry, no. As stated previously, I'm assuming for the purposes of
this analysis that BTFs will be used in cases where (a) we want
lexical "this" and (b) we don't care about "this" at all. Why in the
second case? Because BTF syntax will be more concise and will
generally express the intent better.
When I started this research, I wasn't aware of the "tri-lambda" work
being done, and specifically the proposal that there be two short
function syntaxes: one for classic functions (->) and one for bound
this (=>). Clearly some of the BTF candidates could go either way,
and we really can't make that distinction in this analysis.
kevin
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss