[RFC] Add an operator for ranges to D. Pros and cons?
Dejan Lekic
dejan.lekic at gmail.com
Wed Nov 7 05:16:33 PST 2012
On Wednesday, 7 November 2012 at 13:07:13 UTC, Dejan Lekic wrote:
> Dear D community, I do not know about You, but I certainly do
> not like writing code like:
>
> inRange.fooRange(param).barRange.
> .bazRange(param1, param2).outRange;
>
> I also tried to use operators ">>" and "~" but these make it
> confusing and hard to understand what the statement actually
> does.
>
> Therefore I would like to know what do you think about the idea
> of having additional operator exclusively made for ranges? This
> operator would make it obvious that data are "streamed" (lack
> of better term) among ranges.
>
> The first name I could come up with was "opArrow" but "opData"
> could also be okay, and operator would be either "~>" or "->".
>
> This would give us an obvious, unambiguous statement:
>
> Console.in ~> filter1(param) ~> fooRange ~> Console.out;
> // Console is an imaginary class/struct
>
> Or:
> arr ~> odd ~> random ~> randomOdd;
>
> I humbly believe that ranges are one of the most important
> concepts in D and that, plus the readability increase are two
> valid reasons for having this new operator.
>
> I am also asking this because my point of view is strictly
> pragmatic - there may be technical reasons why we should not
> have this, or why we should have it done some other way, so
> please share your opinion.
>
> Kind regards
EDIT:
I really dislike that word "streamed" that I used. "Chained"
would perhaps be a better one. :)
More information about the Digitalmars-d
mailing list