Re: Named `this` and `this` destructuring

2015-06-18 Thread Jussi Kalliokoski
On Wed, Jun 17, 2015 at 11:38 PM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Jun 17, 2015, at 10:01 AM, Jussi Kalliokoski wrote: ... More examples of the power of the bind syntax can be found in the links, but the bind syntax combined with my proposal would for example allow this:

Re: Named `this` and `this` destructuring

2015-06-17 Thread Jussi Kalliokoski
On Wed, Jun 17, 2015 at 10:35 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: OK **that one** I've no idea what supposes to improve exactly ... I should have tried to realize your proposal better, apologies. After seeing that, I probably agree with Allen at this point we don't

Re: Named `this` and `this` destructuring

2015-06-17 Thread Andrea Giammarchi
OK **that one** I've no idea what supposes to improve exactly ... I should have tried to realize your proposal better, apologies. After seeing that, I probably agree with Allen at this point we don't really need that kind of syntax around JS (still IMHO, of course) Best Regards On Wed, Jun 17,

Re: Named `this` and `this` destructuring

2015-06-17 Thread Allen Wirfs-Brock
On Jun 17, 2015, at 10:01 AM, Jussi Kalliokoski wrote: ... More examples of the power of the bind syntax can be found in the links, but the bind syntax combined with my proposal would for example allow this: ```JS function add (a, b) { return a + b; } 2::add(3) // 5 ``` and why

Re: Named `this` and `this` destructuring

2015-06-17 Thread Andrea Giammarchi
the ::bind syntax is OK (I don't really like that double colon 'cause it's not semantic at all with the single colon meaning but I can live with it) but having potential bitwise-like operators around to adress a possible context ... well, I wouldn't probably use/need that in the short, or even

Re: Named `this` and `this` destructuring

2015-06-17 Thread Jussi Kalliokoski
On Wed, Jun 17, 2015 at 10:45 PM, Andrea Giammarchi andrea.giammar...@gmail.com wrote: the ::bind syntax is OK (I don't really like that double colon 'cause it's not semantic at all with the single colon meaning but I can live with it) but having potential bitwise-like operators around to

Re: Re: Named `this` and `this` destructuring

2015-06-17 Thread Jason Kuhrt
Exactly what Allen said. Adding syntax to work around a bad feature is an awful idea. We should be trying to reduce and remove usage of `this` by reducing resistance to other ways of programming in JavaScript. Minimal API Surface areas apply to languages, not just libraries.

Re: Named `this` and `this` destructuring

2015-06-17 Thread Andrea Giammarchi
Mostly every Array extra in ES5 would work with those functions, e.g. ```js function multiplyPoints (_p2) { var { x1: x, y1: y } = this; var { x2: x, y2: y } = _p2; return { x: x1 * x2, y: y1 * y2 }; } var multiplied = manyPoints.map(multiplyPoints, centralPoint); ``` It's not that common

Re: Named `this` and `this` destructuring

2015-06-17 Thread C. Scott Ananian
Could you include some examples of *calling* functions defined this way? The most obvious way uses `Function#call` and would be terribly awkward. Perhaps I'm just overlooking some ES6 feature which makes passing a specific `this` value easy? It seems curious that you are not using methods instead

Re: Named `this` and `this` destructuring

2015-06-17 Thread Andrea Giammarchi
I forgot to mention that those functions I use as both methods and map/filters are most of the time **private** , and yet we haven't introduced private methods within current class specification. Functions with a `this` are very portable/handy within closures, combined with Array extras and

Re: Named `this` and `this` destructuring

2015-06-17 Thread Allen Wirfs-Brock
On Jun 17, 2015, at 8:09 AM, Andrea Giammarchi wrote: Mostly every Array extra in ES5 would work with those functions, e.g. ```js function multiplyPoints (_p2) { var { x1: x, y1: y } = this; var { x2: x, y2: y } = _p2; return { x: x1 * x2, y: y1 * y2 }; } var multiplied =