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=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham 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 8574D1F462 for ; Fri, 14 Jun 2019 10:30:56 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id E6301120B8B; Fri, 14 Jun 2019 19:30:49 +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 994EE120ACA for ; Fri, 14 Jun 2019 19:30:46 +0900 (JST) Received: by filter0004p3iad2.sendgrid.net with SMTP id filter0004p3iad2-13801-5D037757-13 2019-06-14 10:30:47.282228956 +0000 UTC m=+841452.490353234 Received: from herokuapp.com (unknown [107.21.31.174]) by ismtpd0015p1iad1.sendgrid.net (SG) with ESMTP id LXYjKBB4Tnmgkkrc5OicDA for ; Fri, 14 Jun 2019 10:30:47.095 +0000 (UTC) Date: Fri, 14 Jun 2019 10:30:47 +0000 (UTC) From: mail@tinco.nl Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68621 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15799 X-Redmine-Issue-Author: nobu X-Redmine-Sender: d-snp 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?uGFz4xhVpY5kA8PiDZy7iURVjakBO71yPFXfHD80sCcKgaO92z0IA6ey8T9+cJ?= =?us-ascii?Q?+cJiigVg0FuDV+EiYE21ODpmmq1mpxSyTZ11a20?= =?us-ascii?Q?uMK8BDa7FsTvjnltJmbSxkjs7a8A22SyK2p0Zl2?= =?us-ascii?Q?ZvLihyaGWmsH28QO3DEIYHFQuPqhfI+SAT+wBVN?= =?us-ascii?Q?efocT0bAEQwyD?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93135 Subject: [ruby-core:93135] [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 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/