Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function pipe operator #16900

Open
DartBot opened this issue Feb 17, 2014 · 20 comments

Comments

@DartBot
Copy link

@DartBot DartBot commented Feb 17, 2014

This issue was originally filed by @chalin


Both AngularDart and Polymer have special syntax in support of function pipes (for Filters and Transformers) through the pipe | (bar) operator. E.g.

    person.lastName | uppercase

It would seem a natural fit for Dart to have native support for such a pipe operator. A case for the addition of a pipe operator in Dart is given here: http://pchalin.blogspot.com/2014/02/case-for-pipe-operator-in-dart.html

As is mentioned in the blog entry, I believe that added support should be considered for function composition operators (forward and/or reverse) as well.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Feb 17, 2014

This comment was originally written by @chalin


It just occurred to me that Dart already supports operator definitions and that the bar (|) operator is among the supported operator symbols. I suppose then, that all we need is for the dart:core Function class to be enhanced with a bar operator definition.

@kevmoo

This comment has been minimized.

Copy link
Member

@kevmoo kevmoo commented Feb 17, 2014

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Feb 18, 2014

This comment was originally written by @zoechi


This is a nice idea but | is already in use for bitwise OR.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Feb 18, 2014

This comment was originally written by @chalin


Re #­1. On second thought, adding a bar operator to the Function class would not work since in an expression like x | F the receiver is x not F and hence bar would have to be declared for x. Thus to support this as a method, it would need to be added to Object, ... or given some special support by the compiler.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Feb 18, 2014

This comment was originally written by @chalin


Re #­3. There is no fixed prescriptive use of operators in Dart. I.e., Dart supports operator overloading see [1], Table 2.11. Operators that can be overridden. Notice that the bar operator is part of the list.

[1] https://www.dartlang.org/docs/dart-up-and-running/contents/ch02.html#classes-operators

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Apr 28, 2014

This comment was originally written by @vicb


see https://code.google.com/p/dart/issues/detail?id=18485

@kevmoo

This comment has been minimized.

Copy link
Member

@kevmoo kevmoo commented Apr 28, 2014

Issue #18485 has been merged into this issue.


cc @gbracha.

@kevmoo

This comment has been minimized.

Copy link
Member

@kevmoo kevmoo commented Apr 28, 2014

Here's a vote for the F#-like "|>" syntax. We avoid overloading the behavior of bit-wise.


Set owner to @gbracha.

@gbracha

This comment has been minimized.

Copy link
Contributor

@gbracha gbracha commented Apr 29, 2014

There are useful details in the duplicate issue #18485. Something along these lines is definitely possible, but it will take time - not because it is hard, but because we now have a standards process.


Added Accepted label.

@lrhn

This comment has been minimized.

Copy link
Member

@lrhn lrhn commented Apr 29, 2014

Issue #18516 has been merged into this issue.


cc @floitschG.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Apr 29, 2014

This comment was originally written by @chalin


Again, thanks for promoting function pipes Kevin. I agree that new syntax for piping makes more sense; I had originally proposed use of | because it matched what Angular and Polymer use.

but it will take time ... because we now have a standards process.

In that case, I would hope that the added support of function composition (mentioned at the end of the original entry for this issue) will be considered at the same time. Should I open a separate issue to track this?

@kevmoo

This comment has been minimized.

Copy link
Member

@kevmoo kevmoo commented Apr 29, 2014

RE #­11 from pchalin:

Please open a separate issue. We could offer method piping without providing a general model for method composition.

@DartBot

This comment has been minimized.

Copy link
Author

@DartBot DartBot commented Apr 29, 2014

This comment was originally written by @chalin


Doen: https://code.google.com/p/dart/issues/detail?id=18522

@yjbanov

This comment has been minimized.

Copy link

@yjbanov yjbanov commented Aug 22, 2015

Has anyone started or is anyone interested in starting a DEP for this?

@chalin

This comment has been minimized.

@kevmoo

This comment has been minimized.

Copy link
Member

@kevmoo kevmoo commented Mar 13, 2018

@chalin – you know I'm a fan!

@yjbanov

This comment has been minimized.

Copy link

@yjbanov yjbanov commented Mar 19, 2018

I think Dart should take advantage of the static type system. Could, for example, extension methods satisfy most of the pipeline operator use-cases, without the additional call syntax?

@sclee15

This comment has been minimized.

Copy link

@sclee15 sclee15 commented Apr 15, 2018

I love |> in Elixir! I miss the pipe operator alot in Dart

@darting

This comment has been minimized.

Copy link

@darting darting commented Jul 25, 2019

Hey, any news?

@munificent

This comment has been minimized.

Copy link
Member

@munificent munificent commented Jul 25, 2019

No news. We've been very focused on non-nullable types and extension methods, so haven't had time for many other small-scale language changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Language Enhancement Categories
Non-Breaking And Simple
9 participants
You can’t perform that action at this time.