wrong isInputRange design
rumbu via Digitalmars-d
digitalmars-d at puremagic.com
Tue Dec 6 12:09:24 PST 2016
On Monday, 5 December 2016 at 21:51:28 UTC, pineapple wrote:
> On Sunday, 4 December 2016 at 11:18:56 UTC, rumbu wrote:
---
>
> If you really wanted an `isInputRange` that behaves like you're
> wanting, it's only a 6 line template that you would have to
> interject in your code.
>
> enum bool isInputRange(T) = is(typeof({
> T range = T.init;
> if(range.empty){}
> auto element = range.front;
> range.popFront();
> }));
>
> https://github.com/pineapplemachine/mach.d
My post was about a wrong design decision which generates a
compiler error just with one symbol import. If I didn't know how
to solve this, I would probably post in the learn section :)
After I read the Jonathan's explanations, I understood that it's
my fault, one must guess which is the proper way to use a
standard library, so I didn't bother to continue the discussion.
Anyway, you have a very nice library that just proves my point
that a better design is possible: the "asrange" solution for
arrays is very elegant.
Finally, for my library I decided to completely ignore the range
concept, I just check for isIterable and do my processing in a
foreach loop.
More information about the Digitalmars-d
mailing list