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 C0CF11F462 for ; Sun, 16 Jun 2019 08:11:38 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id B3F40120C28; Sun, 16 Jun 2019 17:11:31 +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 D504F120C0F for ; Sun, 16 Jun 2019 17:11:27 +0900 (JST) Received: by filter0136p3mdw1.sendgrid.net with SMTP id filter0136p3mdw1-12524-5D05F9B0-32 2019-06-16 08:11:28.990408357 +0000 UTC m=+229999.591549653 Received: from herokuapp.com (unknown [3.84.21.142]) by ismtpd0037p1mdw1.sendgrid.net (SG) with ESMTP id VQYuq6eTTDSBSqNCXP3L8Q for ; Sun, 16 Jun 2019 08:11:28.958 +0000 (UTC) Date: Sun, 16 Jun 2019 08:11:29 +0000 (UTC) From: josh.cheek@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68661 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15799 X-Redmine-Issue-Author: nobu X-Redmine-Sender: josh.cheek 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?G9ydTtk2SJoSGpJrwmaKWlNzSJSRPYgrzFotqb=2FkjI2h5OHGLQ9JSOeCxvfk1Z?= =?us-ascii?Q?exHcxNebF5zPPa7l=2FEwkj2lknJ7chqhD364r=2F=2FL?= =?us-ascii?Q?xmQj7K93JStkIOn0=2F1Gu7cchxBI5S19rFYS4CKx?= =?us-ascii?Q?LU5N7RDpXTK7cyKvqANSc2D=2FiOSLp+U1YvQtmFr?= =?us-ascii?Q?urC3+GiOgcjOoiqeyN9aIStyQjFuI6OYB3A=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 93175 Subject: [ruby-core:93175] [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 josh.cheek (Josh Cheek). The operator doesn't bother me, though I can't think of any time I'd use it. Several suggested alternatives seem to want to leave the syntax ambiguous, leaving it unclear whether the piped thing is the receiver or the arg and its unclear where the method comes from. This means the syntax would remain ambiguous until execution time. You could potentially add a method in one location, which caused the syntax to change in another. I think Haskell's dollar sign would be more useful. It lowers precedence, which, would also allow dropping of parentheses. From @mame's blog, it sounds like that's the purpose of this operator. ```ruby x = 1.. $ .take 10 $ .map {|e| e*2} x # => [2, 4, 6, 8, 10, 12, 14, 16, 18, 20 p 10.times.map $ do |i| 2*Math::PI*i/10 end # >> [0.0, 0.6283185307179586, 1.2566370614359172, 1.8849555921538759 1 + 2 $ * 3 # => 9 ``` The downside of using `$` is that it may conflict with the Perl style hooked variables. ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-78616 * 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/