From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 2E2A31F462 for ; Fri, 14 Jun 2019 06:16:05 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 6395A120BB2; Fri, 14 Jun 2019 15:15:58 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 6CC29120BCA for ; Fri, 14 Jun 2019 15:15:55 +0900 (JST) Received: by filter0134p3las1.sendgrid.net with SMTP id filter0134p3las1-27232-5D033B9D-7 2019-06-14 06:15:57.188746267 +0000 UTC m=+49723.251107161 Received: from herokuapp.com (unknown [107.21.31.174]) by ismtpd0052p1mdw1.sendgrid.net (SG) with ESMTP id Pyx5eKFETsGlUiUXMtP7cw for ; Fri, 14 Jun 2019 06:15:57.112 +0000 (UTC) Date: Fri, 14 Jun 2019 06:15:57 +0000 (UTC) From: keystonelemur@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68616 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15799 X-Redmine-Issue-Author: nobu X-Redmine-Sender: baweaver X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?XlD0LGPYDDjb=2FA1CQKGKXgvLTTlhHMIrQD1g5Sx7EbKOsOA0qH7TOwSIWwqZfQ?= =?us-ascii?Q?c85ZckLuTFYoqOhZ93KSTPzlkySd49xQtHGVxgU?= =?us-ascii?Q?Wc7NVJE7vdI4ZYNGeABNOcRyZUCepT9qMx3f=2FpY?= =?us-ascii?Q?6XSZ6ylduxtjGzeo+rp3Q3mn6EcvjnqBO7357yS?= =?us-ascii?Q?j9dMiTFk+YErMWilH52uGvbjEt1kwmXrFiw=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93130 Subject: [ruby-core:93130] [Ruby trunk Feature#15799] pipeline operator X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15799 has been updated by baweaver (Brandon Weaver). That's a very fair point @jeremyevans0, it would introduce two lookup chains even under the most ideal of circumstances. Perhaps if `&` were slightly extended, one could do this: ```ruby def double(n) n * 2 end increment = -> n { n + 1 } 5 |> &double |> &increment |> to_s(2) |> reverse |> to_i ``` ...wherein `&` would retain its meaning of coercing something to a proc, make the call chain more explicit, and kill the speed hit potential. The downside is it would add a feature to `&` that it could convert a method to a proc which does not currently exist and would do all types of interesting things to the interpreter for parens. It had been mentioned in the past to have anonymous or self-oriented `.:` to get around this: ```ruby 5 |> &.:double |> &increment |> to_s(2) |> reverse |> to_i ``` Though that presents issues of 2+ arity functions. It's certainly a hard issue to solve for, but if a solution can be found it would be extremely powerful for the language. ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-78559 * 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/