2 ms·
For the sake of history, `range` was found/coined by Andrei [1] [2] as a way to overcome the issues with the iterator pattern (in STL). I wish Eric Niebler cred
by arunc 8y ago
For the sake of history, `range` was found/coined by Andrei [1] [2] as a way to overcome the issues with the iterator pattern (in STL). I wish Eric Niebler credited Andrei somewhere, but I couldn't find any.
Honest question: why should I use ranges after all?
As I understand, ranges are the core of idiomatic D and they are not worth it (as per OP)?
AFAIK, ranges (at least in D) are not thread-safe [3]. So what real benefits does it bring?
[1] https://accu.org/content/conf2009/AndreiAlexandrescu_iterators-must-go.pdf https://accu.org/content/conf2009/AndreiAlexandrescu_iterato...
[2] http://www.informit.com/articles/printerfriendly/1407357 http://www.informit.com/articles/printerfriendly/1407357
[3] https://github.com/carun/parallel-read-tester/commit/3e69da45bfe6820d3a93d28a61e1608bfbb945ed https://github.com/carun/parallel-read-tester/commit/3e69da4...
- atilaneves 8y agoI wrote the blog post and I definitely think ranges are worth using, and said as much in the link. I just don't think they're worth it in this particular case. The code is usually clearer and more reusable with ranges, and if by chance they're bottleneck (unlikely) then rewrite into raw for loops.
- arunc 8y agoThanks!
- pfultz2 8y ago> For the sake of history, `range` was found/coined by Andrei No it wasn't. Boost.Range library predates Andrei's Range talk in 2009. Boost.Range was introduced in boost 1.32, which was released in 2004: https://www.boost.org/users/history/version_1_32_0.html https://www.boost.org/users/history/version_1_32_0.html And from Boost.Range's "History and Acknowledgement" it explains where the term came from: > The term Range was adopted because of paragraph 24.1/7 from the C++ standard https://www.boost.org/doc/libs/1_32_0/libs/range/doc/history_ack.html https://www.boost.org/doc/libs/1_32_0/libs/range/doc/history... Furthermore, what is being standardized in C++ is an expansion of what is in Boost.Range, which uses iterators underneath. Andrei's term for ranges(and what is in D) are actually quite different as it removes the basis for iterators completely.