--- Comment #6 from Andrei Alexandrescu <> 2011-12-29 
15:50:54 PST ---
(In reply to comment #4)
> (In reply to comment #3)
> > Let me add that it's not impossible there are ranges that do have
> > multi-dimensional slicing but possibly no notion of "length". Sparse 
> > matrices
> > come to mind.
> Yes. Another difference is that length is generally an integer. opDollar
> doesn't need to be, it could be any object. It can also be cheap to calculate
> opDollar but expensive to determine length.
> I guess the question is, for what fraction of use cases will opDollar and
> length coincide?

Given a value x of type T, if the user is able to write both



x[0 .. $]

then it should be reasonable to expect the latter is interchangeable with x[0
.. x.length].

> It seems to be true for most ranges, which is interesting because they didn't
> even exist when this feature was first implemented -- it was designed for
> matrices -- yet they're now shaping us an important use of it. I don't think
> that there will be much application code that uses multi-dimensional opDollar,
> so it doesn't matter so much if those cases have a fair bit of boilerplate.
> How commonly will people declare new ranges in application code?

Hard to estimate, but I suspect a fair amount (and we want to encourage that).
In STL defining an iterator is an act of courage, but we'd ideally hope that
people can easily define ranges that integrate with a variety of algorithms.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to