Issue with forward ranges which are reference types
Jonathan M Davis
jmdavisProg at gmx.com
Tue Aug 16 21:37:03 PDT 2011
On Tuesday, August 16, 2011 23:26:37 Andrei Alexandrescu wrote:
> On 8/16/11 11:05 PM, Jonathan M Davis wrote:
> > Sorry that this is long, but it's very important IMHO, and I don't know
> > how to make it much shorter and cover what it's supposed to cover.
>
> [snip]
>
> Keep things as they are. Algorithms operate on ranges as specified in
> their signatures. If they need to create additional copies thereof, they
> use .save. If client code needs to pass a copy of a range to an
> algorithm, it passes .save.
I expect that the result of that is that reference type ranges aren't going to
work a lot of the time. Now, how much of that is broken implementations and
how much of it is actual design issues, I don't know.
It's clear to me however that we need to start having unit tests for reference
type ranges in Phobos (probably both of the struct and the class variety to be
on the safe side) to make sure that functions at least work correctly when
they're passed a reference type range, regardless of whether the range gets
consumed in the process. I expect that we have quite a few bugs in Phobos
stemming from the fact that pretty much all of the ranges that we test with
(and that most people use at in general at this point) are value type ranges.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list