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_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 822D61F453 for ; Sat, 27 Apr 2019 14:19:34 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id C79071209EF; Sat, 27 Apr 2019 23:19:28 +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 F1185120974 for ; Sat, 27 Apr 2019 23:19:25 +0900 (JST) Received: by filter0181p3mdw1.sendgrid.net with SMTP id filter0181p3mdw1-25487-5CC464ED-E 2019-04-27 14:19:25.336408206 +0000 UTC m=+149448.779058473 Received: from herokuapp.com (unknown [3.88.222.166]) by ismtpd0004p1iad1.sendgrid.net (SG) with ESMTP id z2_nNLViQG2kRFn9-wDiLw for ; Sat, 27 Apr 2019 14:19:25.311 +0000 (UTC) Date: Sat, 27 Apr 2019 14:19:25 +0000 (UTC) From: shevegen@gmail.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 67921 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15799 X-Redmine-Issue-Author: nobu X-Redmine-Sender: shevegen 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?6lbdtOg4RDRLuxD00eQtQKgoNAsge5d4xND7cbMQd0zMtz=2FhZCsURbuV9SXOj0?= =?us-ascii?Q?jfG3=2FzekMxOxqfl7Ez4axkKjugUyg50rUskpSBs?= =?us-ascii?Q?dqhugMG1Uov5yU51IRSxAoikTWGZDhunsOM5asE?= =?us-ascii?Q?Cf5T4GUinTV=2Fk+El58aSRKN4jkuPy69m1AVQsWf?= =?us-ascii?Q?bx=2FnHAUYlQFmoxk1hey51nnG9HSG+2Uqq+Q=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92438 Subject: [ruby-core:92438] [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 shevegen (Robert A. Heiler). > I think there is nothing wrong with having parentheses for Range, I > think they actually help readability. My comment is not meant in regards to the example given for Range, but more in general. I am not sure if having mandatory parentheses is a (visual/syntactic) improvement. Python folks often claim this, while forgetting that you can easily use () in ruby. I myself like to avoid (), but I never avoid them when I do "def foobar(a, b, c)". This is often just to satisfy the expectation that I have when looking at ruby code; my brain works easier/faster for method definitions having (). I don't have any particularly strong preference for () elsewhere, though. There is one slight problem in regards to syntax diversification in general - it can make the code that ruby users write difficult for others to read. You mentioned Haskell lateron, and I remember an older discussion on #gobolinux with a hacker from denmark (oejet) who was using Haskell. Back then he stated that writing haskell is quite easy for him, but reading haskell is quite difficult. While ruby is, in my opinion, much easier than haskell, I think adding syntax flexibility, while this in itself is not necessarily bad, and it may add new feature to ruby, it makes it hard(er) to work with code written by other people. Of course it may be great for individual freedom, but for larger projects I think this may be somewhat ... hmm, more difficult. I myself would not be able to adjust to projects that would use features that I do not use in my own code base. (Although I also tend to avoid looking at ruby code written by other people these days, because there is so much terrible code out there ... I am sure others may say this about my own code bases too ;)). > Martin's desugared version which works today is actually shorter and > I believe most would agree it's also clearer. Yes - I have this often with some other changes too. Oldschool ruby beats many newer additions (syntax-wise; I don't think people have much against features/functionality per se, but I myself think that syntax is hugely important too. Otherwise we could use languages with a terrible syntax.) Note that I do not have a huge preference in this regard though. I slightly dislike |> but not so much because of the syntax, more that to me it feels as if it came from elixir and people who are in favour of the syntax seem to be elixir-users who cross language ideas. It is not even against ruby's "philosophy" per se, since matz always tried to make it convenient for people to use ruby (e. g. collect versus map, people use whichever variant they prefer), but I still don't feel it is necessarily a great idea to adopt syntax that works very well in other languages. My opinion is that this often just does not work well in e. g. ruby. People seem to base their reasoning largely on their own personal preferences primarily; I guess one can say the same about people disliking any feature/change, too. :) > To be fair, I don't particularly like Haskell code and find it > very cryptic, which this is getting closer to. Oddly enough, I actually felt that Haskell has a fairly clean syntax. What I dislike about Haskell is the complexity. I don't want to think when I code (yes, I am not the thinker; I am more a random tinkerer; I probe/change at code until it works and does what I want it to do, hopefully). > Also, if we actually introduce a pipeline operator, I think > it's much more useful to have Elixir semantics of passing > the result as the first argument of the RHS, than just a > different syntax for .. Hah! I actually thought that was elixir. :) Now your comment is more similar to Haskell (I don't quite know haskell very well; nor elixir either). But otherwise I agree - I think oldschool ruby is clearer. Still, having said that, what matz once wrote somewhat applies to this here too - you don't have to use it if you dislike it. I do this with a lot of ruby, e. g. I only use a subset of ruby, and I quite happily ignore the rest. :P I guess perhaps there should be more examples given. Right now only nobu gave an example here and I think it would be more fair if others e. g. in particular during rubykaigi but also on the bug tracker, show more examples for the pipeline operator/idea (I don't know what was discussing during ruby kaigi of course; I guess some other folks may also not know that either). ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-77792 * Author: nobu (Nobuyoshi Nakada) * Status: Open * 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 {|x| x*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/