Are iterators and ranges going to co-exist?
Peter Alexander
peter.alexander.au at gmail.com
Mon Jul 19 16:34:33 PDT 2010
On 19/07/10 11:09 PM, Andrei Alexandrescu wrote:
> Phobos' bringToFront does not assume the ranges are adjacent.
> bringToFront is a strict generalization of STL's rotate.
My point still stands: if you want to rotate then you need pass in
adjacent ranges, which burdens the programmer and increases the size of
the algorithm input. Generalizations are good, but specializations are
just as important.
>> - You're returning more data than is often wanted from some functions
>> (such as the planned find).
>
> That's not necessarily a disadvantage, and I think in practice it's
> seldom an issue.
Ok, I agree that's not a very good argument.
> splice is an internal method of the doubly-linked list. As such, it has
> knowledge and access to the list range's implementation and therefore
> has no problem wiring the pointers appropriately. (Note that splice does
> not work with just any ranges.)
True.
> I think the comparison is tenuous - I do agree that we have vectors vs.
> matrices etc., but that doesn't necessarily translate in convincing me
> that there should iterators vs. ranges. Pointers don't have a
> line-specific operation that may make them explode :o).
The analogy was in reference to the unintuitive interfaces:
// Plots a point at the beginning of the line
void plotPoint(Line line)
This is very much like many of the library functions in Phobos:
e.g. from Array:
size_t insertBefore(Stuff)(Range r, Stuff stuff)
Why do we need to give it a range, if we only want to specify one place
in the array?
More information about the Digitalmars-d
mailing list