ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: shevegen@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:92438] [Ruby trunk Feature#15799] pipeline operator
Date: Sat, 27 Apr 2019 14:19:25 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-77792.20190427141924.82e54bd49250b343@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15799.20190427083121@ruby-lang.org

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/

  parent reply	other threads:[~2019-04-27 14:19 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-15799.20190427083121@ruby-lang.org>
2019-04-27  8:31 ` [ruby-core:92432] [Ruby trunk Feature#15799] pipeline operator nobu
2019-04-27 10:28 ` [ruby-core:92433] " duerst
2019-04-27 13:23 ` [ruby-core:92436] " eregontp
2019-04-27 14:19 ` shevegen [this message]
2019-04-28  1:26 ` [ruby-core:92453] " nobu
2019-05-01  1:53 ` [ruby-core:92506] " duerst
2019-05-19 22:05 ` [ruby-core:92725] " jonathan
2019-05-25  1:28 ` [ruby-core:92838] " merch-redmine
2019-05-28  4:54 ` [ruby-core:92869] " konsolebox
2019-05-28  7:37 ` [ruby-core:92872] " konsolebox
2019-05-28  9:33 ` [ruby-core:92873] " matthew
2019-05-28 11:41 ` [ruby-core:92876] " zverok.offline
2019-05-28 13:45 ` [ruby-core:92877] " konsolebox
2019-06-12  6:36 ` [ruby-core:93060] " nobu
2019-06-12 13:35 ` [ruby-core:93073] " zverok.offline
2019-06-13 10:00 ` [ruby-core:93103] " eregontp
2019-06-13 11:43 ` [ruby-core:93105] " shevegen
2019-06-13 13:23 ` [ruby-core:93110] " dgutov
2019-06-13 14:09 ` [ruby-core:93111] " ttilberg
2019-06-14  0:12 ` [ruby-core:93118] " chris
2019-06-14  2:01 ` [ruby-core:93120] " joshua.goodall
2019-06-14  2:51 ` [ruby-core:93122] " keystonelemur
2019-06-14  3:00 ` [ruby-core:93125] " matz
2019-06-14  3:18 ` [ruby-core:93127] " merch-redmine
2019-06-14  5:42 ` [ruby-core:93129] " chris
2019-06-14  6:15 ` [ruby-core:93130] " keystonelemur
2019-06-14  7:45 ` [ruby-core:93133] " matz
2019-06-14  8:28 ` [ruby-core:93134] " keystonelemur
2019-06-14 10:30 ` [ruby-core:93135] " mail
2019-06-14 11:03 ` [ruby-core:93137] " rogeriocfj
2019-06-14 13:15 ` [ruby-core:93141] " cichol
2019-06-14 16:56 ` [ruby-core:93144] " sean.m.huber
2019-06-14 19:30 ` [ruby-core:93145] " konsolebox
2019-06-14 23:12 ` [ruby-core:93149] " dgutov
2019-06-16  0:17 ` [ruby-core:93167] " mame
2019-06-16  0:49 ` [ruby-core:93168] " samuel
2019-06-16  8:11 ` [ruby-core:93175] " josh.cheek
2019-06-16 15:29 ` [ruby-core:93188] " shannonskipper
2019-06-30  9:52 ` [ruby-core:93424] " eregontp
2019-06-30 10:19 ` [ruby-core:93425] " eregontp
2019-06-30 10:38 ` [ruby-core:93426] " eregontp
2019-06-30 11:53 ` [ruby-core:93428] " eregontp
2019-08-29  5:39 ` [ruby-core:94645] [Ruby master " matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-77792.20190427141924.82e54bd49250b343@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).