(...)
  Let's ignore popularity level for the moment, no other proposal has analog of 
`=>` which is a solution for a real problem:

      var self = this;
      function callback() {
          self....
      } 
Sorry, alternatives were evocated. If you had read my last mail (I know it was 
a pretty long one so I don’t blame you), you could have noticed that I proposed 
to use the @-syntax to perform just that. The idea would be that all lambdas 
would have a “bound” this (which would be the biggest distinctive between them 
and functions).
The syntax would be the following :
    “@” + ( “(“ + <argument-list> + “)” )? + ( <expression> | <block> )
And it would allow to solve the “this” problem easily :
    element.onclick = @this.removeFromParent();
    setTimeout((@alert(this)), 10); 

alongside with the other common lambda usage :
    firstChilds = elements.map(@a.firstChild);
    array.reduce(@(a,b) { return (a-b)*(a+b); });
In case you need to pass a function that has not a bound this, you should 
continue to use the “function” keyword as usual :
    var anObjectHasOwnValueOf = Function.prototype.bind.call(function() { 
        return this.hasOwnProperty(“valueOf”); 
    }, anObject);
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to