ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: mail@tinco.nl
To: ruby-core@ruby-lang.org
Subject: [ruby-core:93135] [Ruby trunk Feature#15799] pipeline operator
Date: Fri, 14 Jun 2019 10:30:47 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-78564.20190614103046.cd35a69f81c8dfc4@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15799.20190427083121@ruby-lang.org

Issue #15799 has been updated by d-snp (Tinco Andringa).


From my perspective, the |> operator exists because in functional programming languages you have these increasingly nested function calls which have to end with a stack of parentheses that are hard to read. In Haskell I very frequently use the $ operator for a similar effect. In Ruby this problem is not significant at all, it almost never happens that we have nested parentheses, and in the case we do (like calling methods inside method parameters) the pipeline operator wouldn't be a solution anyway.

I think it's not good to introduce a new operator just for a rare use case that isn't idiomatic Ruby. 

If my employees wrote

```
 a |> method1 b |> method2 c
```

I would correct them that the code could be simplified to

```
a.method1(b).method2(c)
```

Not the other way around.

It's not even very common for Ruby methods to return self.

----------------------------------------
Feature #15799: pipeline operator
https://bugs.ruby-lang.org/issues/15799#change-78564

* Author: nobu (Nobuyoshi Nakada)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Implemented the pipeline operator `|>`, a topic of "ruby committers vs the world" in RubyKaigi 2019.
Also a casual idea of rightward assignment.

```ruby
1.. |> take 10 |> map {|e| e*2} |> (x)
p x #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```

https://github.com/nobu/ruby/tree/feature/pipeline




-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2019-06-14 10:30 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15799.20190427083121@ruby-lang.org>
2019-04-27  8:31 ` [ruby-core:92432] [Ruby trunk Feature#15799] pipeline operator nobu
2019-04-27 10:28 ` [ruby-core:92433] " duerst
2019-04-27 13:23 ` [ruby-core:92436] " eregontp
2019-04-27 14:19 ` [ruby-core:92438] " shevegen
2019-04-28  1:26 ` [ruby-core:92453] " nobu
2019-05-01  1:53 ` [ruby-core:92506] " duerst
2019-05-19 22:05 ` [ruby-core:92725] " jonathan
2019-05-25  1:28 ` [ruby-core:92838] " merch-redmine
2019-05-28  4:54 ` [ruby-core:92869] " konsolebox
2019-05-28  7:37 ` [ruby-core:92872] " konsolebox
2019-05-28  9:33 ` [ruby-core:92873] " matthew
2019-05-28 11:41 ` [ruby-core:92876] " zverok.offline
2019-05-28 13:45 ` [ruby-core:92877] " konsolebox
2019-06-12  6:36 ` [ruby-core:93060] " nobu
2019-06-12 13:35 ` [ruby-core:93073] " zverok.offline
2019-06-13 10:00 ` [ruby-core:93103] " eregontp
2019-06-13 11:43 ` [ruby-core:93105] " shevegen
2019-06-13 13:23 ` [ruby-core:93110] " dgutov
2019-06-13 14:09 ` [ruby-core:93111] " ttilberg
2019-06-14  0:12 ` [ruby-core:93118] " chris
2019-06-14  2:01 ` [ruby-core:93120] " joshua.goodall
2019-06-14  2:51 ` [ruby-core:93122] " keystonelemur
2019-06-14  3:00 ` [ruby-core:93125] " matz
2019-06-14  3:18 ` [ruby-core:93127] " merch-redmine
2019-06-14  5:42 ` [ruby-core:93129] " chris
2019-06-14  6:15 ` [ruby-core:93130] " keystonelemur
2019-06-14  7:45 ` [ruby-core:93133] " matz
2019-06-14  8:28 ` [ruby-core:93134] " keystonelemur
2019-06-14 10:30 ` mail [this message]
2019-06-14 11:03 ` [ruby-core:93137] " rogeriocfj
2019-06-14 13:15 ` [ruby-core:93141] " cichol
2019-06-14 16:56 ` [ruby-core:93144] " sean.m.huber
2019-06-14 19:30 ` [ruby-core:93145] " konsolebox
2019-06-14 23:12 ` [ruby-core:93149] " dgutov
2019-06-16  0:17 ` [ruby-core:93167] " mame
2019-06-16  0:49 ` [ruby-core:93168] " samuel
2019-06-16  8:11 ` [ruby-core:93175] " josh.cheek
2019-06-16 15:29 ` [ruby-core:93188] " shannonskipper
2019-06-30  9:52 ` [ruby-core:93424] " eregontp
2019-06-30 10:19 ` [ruby-core:93425] " eregontp
2019-06-30 10:38 ` [ruby-core:93426] " eregontp
2019-06-30 11:53 ` [ruby-core:93428] " eregontp
2019-08-29  5:39 ` [ruby-core:94645] [Ruby master " matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-78564.20190614103046.cd35a69f81c8dfc4@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).