Iterators and Ranges: Comparing C++ to D to Rust
Ola Fosheim Grøstad
ola.fosheim.grostad at gmail.com
Mon Jun 14 13:45:14 UTC 2021
On Monday, 14 June 2021 at 13:30:52 UTC, Ali Çehreli wrote:
> popFront() consumes the range, not the container:
I glossed over the presentation, and I don't think he really
covered things as well as he should. For instance there is a
difference between generators,
nonconsuming-iterators/table–pointers, consuming-iterators, but
sometimes the distinction is blurry.
What if you create a range that consumes a queue. What if you
create a range that interpolates and doubles the length of the
source.
What if you want to modify the underlying container while
iterating over it.
It would be nice with an ontology for table-pointers, iterators
and generators, along the lines of the original Gang of Four book
on design patterns, but I didn't really feel this presentation
brought anything to the table. His take on this was very
"syntactical".
Also, his assumptions about performance were not really well
founded. You have to look at how iterators are used in actual
alogrithms and how that could block optimizations to say anything
sensible about that.
E.g. his take on StopIteration in Python is not really correct
either, you can write a generator (coroutine) with no explicit
StopIteration (although the semantics implies a raised exception,
but that does not mean the implementation has to).
More information about the Digitalmars-d
mailing list