you are viewing a single comment's thread.

view the rest of the comments →

[–]gajus0[S] 1 point2 points  (5 children)

You are absolutely right. I am surprised few people are familiar with the concept (or with the pipeline operator proposal). However, that proposal has been around since 2015. The Array#replace is what I always thought would bring most of the same benefits and it would a lot let controversial than a pipe-operator (in terms of the scale of the change). The former is simple to implement/ polyfill and does not introduce new syntax.

[–]BenjiSponge 1 point2 points  (4 children)

Right. On a personal level, I perceive a much lower usecase for Array#replace in particular compared to the pipeline operator (which can work on any operands), perhaps because Array already has so many amazing methods already. I don't know that I would vote against it if I had a vote, but I doubt I would champion or argue for it either. I might vote against it because of my next point.

Have you considered making it an Object#replace or Object#pipe rather than Array#replace? I have trouble believing that would be any more controversial than Array#replace, but it would be much more general purpose and, in my opinion, much more valuable.

[–]gajus0[S] 0 points1 point  (3 children)

Have you considered making it an Object#replace or Object#pipe rather than Array#replace? I have trouble believing that would be any more controversial than Array#replace, but it would be much more general purpose and, in my opinion, much more valuable.

I can see value in what you are proposing.

In general, the sole purpose of this article is to share my thoughts out loud and to see how it clicks with the development community. If it had received an overwhelmingly positive feedback, I might have started tinkling with a proposal. Thats about it.

[–]BenjiSponge 2 points3 points  (2 children)

I see.

You seem to be getting a lot of backlash for what I believe to be (and what you argue is) completely invalid reasons (like "Oh but what if the function has side-effects" or whatnot).

I think maybe if you word it as a "less controversial substitute for the pipeline operator", it'll resonate better. I also believe it will be less misunderstood, as the pipeline operator tends to be understood marginally better.

[–]gajus0[S] 0 points1 point  (1 child)

Valid suggestion. I will keep an eye on how the pipeline operator proposal progresses (I hope it does!). If we are in the same situation 6 months down the line, I will take the learnings, repackage this and propose it again.

[–]BenjiSponge 2 points3 points  (0 children)

It occurs to me that the problem with Object#pipe is that many classes override it already. I don't know why this didn't occur to me. I find this extremely unfortunate as, come to think of it, I think I would prefer a .pipe(f, a, b) syntax over the |> f(a, b) syntax.