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.9 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=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 28ADE1F461 for ; Sun, 30 Jun 2019 09:52:24 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B75371209C4; Sun, 30 Jun 2019 18:52:16 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 8CDCD12099B for ; Sun, 30 Jun 2019 18:52:14 +0900 (JST) Received: by filter0047p3las1.sendgrid.net with SMTP id filter0047p3las1-32743-5D18864F-1C 2019-06-30 09:52:15.778395151 +0000 UTC m=+141957.586296274 Received: from herokuapp.com (unknown [3.94.122.70]) by ismtpd0012p1iad1.sendgrid.net (SG) with ESMTP id -X7JRMOzRGuhEe4sRvFPTw for ; Sun, 30 Jun 2019 09:52:15.629 +0000 (UTC) Date: Sun, 30 Jun 2019 09:52:15 +0000 (UTC) From: eregontp@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68917 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15799 X-Redmine-Issue-Author: nobu X-Redmine-Sender: Eregon 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?KippOI8ZHtTweq7XfQzW93937kJ4QNWwSBuHnaMEcr0jZrsiPQesBSXglUgZZr?= =?us-ascii?Q?agozjvEO82Untx1zIwzSzHapk=2FfbwDE1ULH+3gj?= =?us-ascii?Q?c3H5RDHUHCZqficI6thZBnkL=2FsFYH0D7C6pQpLK?= =?us-ascii?Q?pkhr=2FAec44fEVXRBpOWG7t4RVb2jhavhBmPZlYi?= =?us-ascii?Q?OX4kykYFOJh3kOWisElhpHOQOlDfBQKRq=2FA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93424 Subject: [ruby-core:93424] [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 Eregon (Benoit Daloze). inopinatus (Joshua GOODALL) wrote: > ``` ruby > result = 3 |> pow(2) #=> 9 > result #=> 3 (!?!?!) > ``` This makes it clear to me: the pipeline operator just seems a hack to avoid parentheses around Range literals. The precedence seems not intuitive. Unlike `and`, where `if a = 3*2 and a == 6` is rather clear, here assignment before |> is never wanted. So probably assignment before |> should be a SyntaxError. This syntax saves Range literal parenthesis, but it doesn't even save characters, so I see not point for it as it is. Others will say it's nice for multi-line method call chains, but `.` works just fine in that case too when using indentation: ```ruby 1.. |> take 10 |> each { |x| p x } (1..) .take(10) .each { |x| p x } ``` (the example is from @mame's post) Finally, as other have said, the most essential operator of OO languages, the method call operator, does not need to be reinvented, `.` works just fine. ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-78966 * 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/