Shout out to D at cppcon, when talkign about ranges.
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Thu Oct 1 00:37:25 PDT 2015
On Thursday, 1 October 2015 at 05:47:25 UTC, Eric Niebler wrote:
> On Thursday, 1 October 2015 at 04:08:00 UTC, bitwise wrote:
>> I understand, but the C++ committee seems very conservative to
>> me, so when it's this easy to add for(:) support by giving
>> ranges begin()/end() functions, it makes me doubt they will
>> actually change the language for it.
>
> As of C++11, C++ has the for(auto e:range) control structure
> you are looking for. I would be using it here except for one
> thing: in my proposal, begin() and end() don't have to return
> objects of the same type! begin() must return an iterator and
> end() must return something that is EqualityComparable with the
> iterator -- but it doesn't have to be an iterator. That makes
> many types of iterators vastly simpler to implement and more
> efficient at runtime.
>
> C++'s built-in range-based for(:) loop expects begin() and
> end() to return objects of the same type. The committee is
> already talking about loosening that constraint so that the
> ranges I'm proposing Just Work with the existing built-in
> looping construct. Until then, there is an ugly macro. It's a
> temporary hack, nothing more.
>
> Hope that clears things up.
>
> Eric
>
That's good news !
> P.S. I see lots of people here assuming that C++ is playing
> catch-up to D because D has ranges and C++ doesn't yet. That is
> ignoring the long history of ranges in C++. C++ got ranges in
> the form of the Boost.Range library by Thorsten Ottoson
> sometime in the early 00's. Andrei didn't implement D's ranges
> until many years after. The ranges idea is older than dirt.
> It's not a D invention.
Well, yes and no. Sure I'm sure there are precedent for ranges,
be it in C++ or even I'm sure one can find them in other
languages. I'm sure someone in the 70s had something like ranges
already.
But for years, it was a fringe idea in the C++ world, the
consensus being the iterator were enough. Meanwhile, D adopted
the idea and ran with it, doing so, proving how powerful the
concept is.
Some may be bitter, but I'm actually happy that C++ is adopting
ranges, as these are a great tool. As long as the Jobs "we
reinvented hot water with shiny corners and it is a revolution"
style of presenting things do not become the norm. On that note,
I think Herb's pissed of a lot of people with his talk. On the
other hand, I think you did a fine job.
More information about the Digitalmars-d
mailing list