Are iterators and ranges going to co-exist?

Walter Bright newshound2 at digitalmars.com
Wed Jul 21 09:22:18 PDT 2010


Peter Alexander wrote:
> I don't see how it is a dual design. Almost all the algorithms
> that use ranges now would remain the same. I don't propose that
> any of that should be changed.

If some algorithms used ranges and others used iterators, the poor programmer 
would find himself then obliged to implement both interfaces for each container.


> All I would like to see is some way to generically point to a
> single element in a range.

range[0] ?


> This is not a massive change, and ranges would still comprise a
> good 95% of the algorithm code; I just think it's odd to use
> ranges for those 5% that would make more sense to use cursors.

There is the massive unsafeness of using iterators. We'd like the whole of the 
algorithms to be guaranteed memory safe, and that cannot happen with iterators.

Being able to statically guarantee memory safety is a huge deal, and the larger 
a program is and the larger the team working on it, the more this matters.



More information about the Digitalmars-d mailing list