there are couple libraries that are build on top of this proposal: https://github.com/jussi-kalliokoski/trine https://github.com/roobie/mori-ext https://github.com/thisables/curry
ECMAScript bind operator proposal
11–20 of 50 posts
Re: ECMAScript bind operator proposal
#12there are couple libraries that are build on top of this proposal: https://github.com/jussi-kalliokoski/trine https://github.com/roobie/mori-ext https://github.com/thisables/curry
Re: ECMAScript bind operator proposal
#13Neat! Extension methods and getting rid of "var that = this;" in one! It seems that it also extends to full expressions on the right-hand side of ::, so you can even do, for using Array operations over things that look like arrays but not quite: document.querySelectorAll('p')::([].map)(f) instead of: [].map.call(document.querySelectorAll('p'), f) (replace [].map with Array.prototype.map if it feels less gross)
[...document.querySelectorAll('p')].map(f)
In the future, NodeList could extend Array which would make these workarounds redundant. Extending Array was made possible by ES6.Anyhow, I think having some kind of extension methods would be great.
Re: ECMAScript bind operator proposal
#14With arrow functions released and class properties likely to be approved soon, this has minimal value and is probably not worth the cost of the extra complexity to the language.
I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…
Re: ECMAScript bind operator proposal
#15Re: ECMAScript bind operator proposal
#16Earlier quoted context omitted.
I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…
Wouldn't a pipeline operator [1] be a more interesting solution for this instead of adding syntax that relies on the `this` keyword? [1] https://github.com/mindeavor/es-pipeline-operator
Re: ECMAScript bind operator proposal
#17Re: ECMAScript bind operator proposal
#18With arrow functions released and class properties likely to be approved soon, this has minimal value and is probably not worth the cost of the extra complexity to the language.
I respectfully disagree. It all has to do with this line: "By providing syntactic sugar for these use cases we will enable a new class of "virtual method" library, which will have usability advantages over the standard adapter patterns in use today." Essentially, you write functions that provide a certain behavior without being coupled to a specific class, so you can have a 'map' method that is called the same way no…
There is nothing that this proposal does that cannot be done today. It brings nothing new to the table aside from operator noise. I hope the committee pushes against these exotic features, like the bind operator or the pipe operator.
> Right now functional libraries like static-land, ramda, sanctuary, etc. are working hard to provide these functional primitives but it's still painful to write readable code that uses these.
No it's not. explicit != painful .
Do people really want to end up with a spec of the size of C++ spec ?
Re: ECMAScript bind operator proposal
#19Neat! Extension methods and getting rid of "var that = this;" in one! It seems that it also extends to full expressions on the right-hand side of ::, so you can even do, for using Array operations over things that look like arrays but not quite: document.querySelectorAll('p')::([].map)(f) instead of: [].map.call(document.querySelectorAll('p'), f) (replace [].map with Array.prototype.map if it feels less gross)
(~R∊R∘.×R)/R←1↓ιRRe: ECMAScript bind operator proposal
#20Is there any other language that uses "this" to denote "current context"?