Named `this` and `this` destructuring

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Jun 17 20:38:35 UTC 2015


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 that better than: 
```js
function add(a,b) {return a+b}

add(2,3);
```

Every new feature increases the conceptual complexity of a language and to justify that it needs to provide a big pay back.  This doesn't seem to have much of a pay back. Adding the & and :: doesn't eliminate the need for JS programmer to learn about `this` in functions for the various already existing ways to call a function with an explicit `this` value.  It just add more new syntax that needs to be learned and remembered are move feature interactions that have to be understood.

JS doesn't need more syntax and semantics piled on to `this`. Ideally some would be taken away.  However, the latter is not possible.

Allen



More information about the es-discuss mailing list