Are iterators and ranges going to co-exist?

Bruno Medeiros brunodomedeiros+spam at com.gmail
Tue Jul 27 13:36:17 PDT 2010


On 20/07/2010 04:27, PercentEwe wrote:
>
> As far as anyone not coming from C++ is concerned, ranges == iterators.
>

Actually, thanks for pointing that out. It took me a while to figure 
that out, as it wasn't immediately clear.

Sure, some D ranges also offer random access and are generally more 
powerful and better abstracted than iterators in other languages, but 
the basic functionality is still iterating/traversing and doing 
something on the current element.

Also, when I think of "range" I think of the mathematical 
range/interval, which have a few aspects that don't match with D ranges:
  * they always have a length, it is "always" known, and "available 
immediatly", so to speak...
  * real ranges (as in real numbers) don't have a set of discrete 
elements, but rather a infinite set of contiguous elements. (except for 
the degenerate cases of course)

Yeah, this is a very minor issue, and can be just my personal bias. But 
its worth to keep in mind if ever you want to explain D ranges to a D 
newbie who is familiar with iterators in languages other than C/C++.

-- 
Bruno Medeiros - Software Engineer


More information about the Digitalmars-d mailing list