Re: Autobinding destructuring

2012-08-05 Thread Claus Reinke
But it also made me realize that by default, destructuring returns unbound methods. ... Agreed that this is an obstacle. With operators, one could have a convenient binding selection, but the destructuring case needs a separate solution. Why does it need a separate solution? Especially if

Re: Autobinding destructuring

2012-08-04 Thread David Bruant
Le 03/08/2012 17:45, David Bruant a écrit : (...) It reminded me of an ECMAScript Regret submitted by Tom about the fact that method are extracted unbound by default. And after a couple of tweets related to 'with' and the canvas API I wonder: would it be worth having another syntactic form

Re: Autobinding destructuring

2012-08-04 Thread Brendan Eich
David Bruant wrote: var context = document.getElementsByTagName('canvas')[0].getContext('2d'); // bikeshed syntax for binding destructuring, my point isn't about syntax here var #{beginPath: begin, moveTo, lineTo, stroke, closePath: end} = context; // extracted methods are

Re: Autobinding destructuring

2012-08-04 Thread Claus Reinke
But it also made me realize that by default, destructuring returns unbound methods. It's perfect for the above use case, but may be annoying when you wish to extract functions bound to the object they're extracted from: var o = {a:1, f: function(){return this.a;}}; var {f} = o;

Re: Autobinding destructuring

2012-08-04 Thread Claus Reinke
[argh, unhelpful hidden key-combo led to premature send] But it also made me realize that by default, destructuring returns unbound methods. It's perfect for the above use case, but may be annoying when you wish to extract functions bound to the object they're extracted from: var o =

Re: Autobinding destructuring

2012-08-04 Thread David Bruant
Le 04/08/2012 17:53, Claus Reinke a écrit : [argh, unhelpful hidden key-combo led to premature send] But it also made me realize that by default, destructuring returns unbound methods. It's perfect for the above use case, but may be annoying when you wish to extract functions bound to the

Autobinding destructuring

2012-08-03 Thread David Bruant
Hi, I wrote some code today: var cos = Math.cos, sin = Math.sin, PI = Math.PI; // later: x1 = x + R*cos(t)*cos(angle) - r*sin(t)*sin(angle); First of all, it made me realize that the usual example of 'with' (using with(Math) and an expression like I showed) turn