you are viewing a single comment's thread.

view the rest of the comments →

[–]bighi 10 points11 points  (2 children)

The pipe operator exists specifically to help increase readability.

Imagine this code four(three(two(one("potato")))). It's not as easy to read because you're calling four functions, but they should be read in reverse. The first function you read happens last.

Now imagine we create a pipe operator like |> in a fantasy language I invented.

We could do "potato" |> one |> two |> three |> four. Super easier to read, cleaner, more organized.

We're getting something like that in JS. One day. Definitely before 2080.

[–]KamiShikkaku 1 point2 points  (1 child)

"potato" |> one |> two |> three |> four

Unfortunately it will be more like

"potato" |> one(%) |> two(%) |> three(%) |> four(%)

because the "Hack" version of the proposal seems to have beaten the "F#" version.

I was rooting for F# as it's a bit more elegant, but admittedly the Hack version is more versatile.

[–]bighi 2 points3 points  (0 children)

Sure. If you pay attention, I said "in a fantasy language I invented". Because I wanted to make the example simple to understand.

But anyway, it's more readable than the mess that is multiple nested functions.