Native Function Composition

Naveen Chawla naveen.chwl at
Fri Aug 25 11:41:17 UTC 2017

Aw, snap! I've written up a much shorter proposal myself. I do think
composition should be in-order of call, i.e.

const composed = a |> b |> c  //c(b(a(f)))
Reads "do a `then` b `then` c"

The advantage is that no-param calls can also be easily chained using the

const switchOnTheEngineThenDrive = switchOnTheEngine |> drive

I also don't think the reverse operator should be allowed. I think it
compromises readability and could introduce confusion.

I've written my shorter proposal here:

On Fri, 25 Aug 2017 at 16:56 Naveen Chawla <naveen.chwl at> wrote:

> On Fri, 25 Aug 2017 at 12:24 Claude Pache <claude.pache at> wrote:
>> > Le 24 août 2017 à 23:13, Naveen Chawla <naveen.chwl at> a écrit
>> :
>> >
>> > That's a syntax for calling functions, not creating a composed function
>> for being called any time.
>> >
>> > Personally I don't find that proposal compelling because I don't think
>> it saves much code vs current syntax - it only straightens the order and
>> replaces () with using |>.
>> Straightening the order is still a big deal in lengthy expressions. And
>> imbalance of nesting parentheses is one of my main sources of syntax errors.
> Yes I think this applies in cases of function composition. My point was
> that it doesn't save much code, especially in comparison to allowing `|>`
> to be used directly as a function composition operator, which would give
> you the linearity you could want, as well as adding a whole dimension of
> expressive power to the language, instead of just allowing a re-ordered way
> of writing existing syntax.
>> —Claude
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list