Why static analysis is the way to go

Walter Bright newshound2 at digitalmars.com
Fri May 29 18:18:45 UTC 2026


On 5/28/2026 5:25 PM, H. S. Teoh wrote:
> You're missing the point. C++ iterators, frankly, stink.
The fatal flaw with C++ iterators is you always need two pieces of data, one for 
the beginning and one for the end. They are only connected with each other by 
the programmer keep track of what goes with what, they are not combined.

Another way to look at it as C++ iterators are an abstraction of pointers, while 
D ranges are an abstraction of arrays.

 > which we got criticized for by C++ folks

The only valid criticism they came up with is the rotate() algorithm cannot be 
done easily with ranges, while it fits well with iterators. I use ranges for 
everything, and I can live with a funky implementation of rotate() as a 
tradeoff. Especially since I never use rotate(). And besides, nothing prevents 
you from writing an iterator in D.


More information about the Digitalmars-d mailing list