I don't like the idea of custom operators only because of readability of code - it can be different for different pieces of code, and so I think it is a larger surface area for bugs, so I think it would be a net negative.
However, I do like the idea of allowing e.g. `+` to be used intuitively and consistently (i.e. with a fixed meaning) between certain data types that are not currently supported, e.g.: Array + Array (array concatenation) Function + Function (function composition) On Fri, 2 Feb 2018 at 22:02 Michael Haufe <t...@thenewobjective.com> wrote: > How would operator precedence work? Would we be restricted to 2-argument > functions only? > > > > On Fri, Feb 2, 2018 at 5:55 AM, Thomas Grainger <tagr...@gmail.com> wrote: > >> I'm porting this from the TypeScript issue tracker, original from: >> https://github.com/Microsoft/TypeScript/issues/2319#issue-60851953 >> >> Since it's very unlikely that the extension methods will ever be >> implemented [in a call-site-rewrite >> manner]( >> https://github.com/Microsoft/TypeScript/issues/9#issuecomment-74302592), >> please consider adding infix operators to enable writing in functional >> style similarly to what can be done in Haskell: >> >> Monoids >> >> ```js >> >> function '+' (left, right) { >> return left.concat(right); >> } >> >> [1, 2, 3] '+' [4, 5]; // [1, 2, 3, 4, 5] >> >> ``` >> >> Monads >> >> ```js >> function '>>=' (promise, bind) { >> return promise.then(bind); >> } >> $.get('/get') '>>=' x => $.post('/save', x + 1) >> ``` >> >> Functors >> >> ```js >> function '.' (inner, outer) { >> return function(value: a) : c { >> return outer(inner(value)) >> } >> } >> >> function f(x) { } >> function g(y) { } >> (f '.' g)(x); // z >> ``` >> >> >> >> Thomas Grainger >> >> _______________________________________________ >> 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