Are iterators and ranges going to co-exist?
bearophile
bearophileHUGS at lycos.com
Wed Mar 21 13:43:16 PDT 2012
Peter Alexander:
> and you've also increased the amount of data you need to pass
> into the function by 33%, violating the "Don't pay for what you
> don't use" philosophy.
The "Don't pay for what you don't use" is a C++ rule, it's not a
D Zen rule. In D you sometimes pay a little if it gives back
enough safety or convenience elsewhere. In D there are usually
ways to not pay, but you have to ask for it explicitly.
> Ranges are brilliant, and maybe you could even call them a
> superset of iterators, but just like we have vectors despite
> having matrices, and points despite having lines, we still want
> iterators even though we have ranges. They are simply different
> things.
There is also a price to pay if you want both abstractions in
Phobos. A single abstraction makes things simpler, more
compatible with each other, etc. Example: D has opApply, but at
the moment nearly nothing in Phobos supports opApply (array() and
foreachType, I'd like a third Phobos thing to support it).
Bye,
bearophile
More information about the Digitalmars-d
mailing list