Are iterators and ranges going to co-exist?

Walter Bright newshound2 at digitalmars.com
Wed Jul 21 01:41:36 PDT 2010


Peter Alexander wrote:
> Out of interest (with the understanding that you accept at least that 
> iterators are useful in some situations), are there any other reasons 
> that you argue against them, other than implementation costs?

The strongest reason against iterators is that they are fundamentally unsafe, as 
Andrei explains in his paper about ranges. An iterator (as we all know) is based 
on a pointer, and is often a thin veneer over a pointer. It cannot be checked 
mechanically to determine if it is safe to increment or dereference.

The problem with supporting a dual range/iterator design in Phobos is the 
library will lose focus, and will become a confusing morass.


More information about the Digitalmars-d mailing list