News for hackers. Stuff that matters.
Re:TypeScript support for ES Next pipeline operator by emmanueloga_ on Friday September 21, 2018 @03:20PM (#18041990)
It is interesting to note the overhead it has to define such simple construct in JavaScript. Pages and pages of a spec, all the work to herd ppl behind the proposal, etc.

In Clojure, the threading macros are awesome and they are not even a language construct, just some ~10 lines of code per macro! [1]

In ML, the pipe operator is even shorter:

    `let (|>) x f = f x`
1: https://github.com/clojure/clojure/blob/4ef4b1ed7a2e8bb0aaaa...
Re:TypeScript support for ES Next pipeline operator by andreareina on Friday September 21, 2018 @11:02PM (#18044219)
I used to think the same, until it was pointed out to me that the semantics have to be nailed down exactly, so that conforming implementations (e.g. Chrome/FF) do the same thing. This includes figuring out how (if at all) it works with generators and async functions, if you want to support implicit lambdas, etc[1]. Clojure and ML (and related languages I imagine) have the advantages that it is expressible in code which at least makes the specification part simpler.

Fortunately the simple version is easily approximated, I have this sprinkled in various files where it's useful:

    const pipeline = (val, ...funcs) => funcs.reduce((a, b) => b(a), val);
[1] https://babeljs.io/blog/2018/07/19/whats-happening-with-the-...