C++ Ranges proposal for the Standard Library
Sean Kelly via Digitalmars-d
digitalmars-d at puremagic.com
Sat Oct 18 09:16:16 PDT 2014
On Friday, 17 October 2014 at 09:17:52 UTC, ZombineDev wrote:
> I saw [this][0] proposal for adding ranges to C++'s standard
> library. The [paper][1] looks at D style ranges, but concludes:
>
>> Since iterators can implement D ranges, but D ranges cannot be
>> used to implement iterators, we conclude that iterators form a
>> more powerful and foundational basis.
>
> What do you guys think?
"Since assembly code can be used to implement Java but java
cannot be used to implement assembly code, we conclude that
assembly code forms a more powerful and foundational basis."
I probably could have chosen that example better, but I hope it
gets my point across. It's always possible to reduce a library
interface to something that's even more stripped-down, which is
by definition more powerful and foundational. But if the user
never wants to work at that low level of abstraction then you're
just imposing an unnecessary burden upon them.
A well-designed library provides power and flexibility in a form
that encourages a good coding style and which inherently reduces
the chance of mistakes. Getting this right is really, really
hard to do. I think D gets it more right than C++ though, across
the board.
Regarding iterators vs. ranges, there are still places where
ranges struggle to meet the facility of iterators. But I don't
think this is a flaw in the concept so much that it's still
fairly new and people are still working out the details. Given
the standardization process for C++, they're probably right to
remain with iterators for now and wait for all the kinks to be
worked out of range design. Maybe get ranges into Boost (if they
aren't there already) and see how it goes. But dismissing ranges
out of hand for not being sufficiently "powerful and
foundational" is just silly.
More information about the Digitalmars-d
mailing list