+1 on the idea, -1 on the execution. Here's a few things to be aware of: - A single unary or binary operator without parentheses is unambiguous where only expressions are allowed. - If the operators directly desugar to lambdas, you'll have functions that look `===`, but aren't. - The operator `-` could be either unary or binary, and `x => -x` and `(a, b) => a - b` are both valid potential desugarings. Similar issues exist for `+`.
On Tue, Jul 11, 2017, 07:15 kai zhu <kaizhu...@gmail.com> wrote: > -1 > i can see this becoming a debugging nightmare in math libraries where its > confused with arithmetic expressions. > > yet-another-alien-syntax to remember when debugging other people's code. > On Jul 11, 2017 03:35, "Vihan Bhargava" <cont...@vihan.org> wrote: > >> As JS/ECMAScript gains more and more of a functional use, I've been >> really wanting a functional operator feature from JS for a while. If you >> aren't familiar with them, they are inspired from haskell along the lines >> of: >> >> ```js >> let add1 = (+); // This is the same as below >> let add2 = (a, b) => a + b; >> ``` >> >> This definitely helps clear up verbosity in reduce statements and related >> functions. Another example would be for sorting: >> >> ```js >> [1,4,3,6].sort((-)); >> ``` >> >> While all operators (namely `=`) wouldn't work as functional operators, I >> think this would be a useful addition to the language. >> _______________________________________________ >> es-discuss mailing list >> es-discuss@mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss