Tricky semantics of ranges & potentially numerous Phobos bugs

Jonathan M Davis jmdavisProg at gmx.com
Mon Oct 15 22:48:15 PDT 2012


On Monday, October 15, 2012 22:09:05 H. S. Teoh wrote:
> The scary thing is, I see similar code like this all over Phobos. Does
> this mean that most of std.algorithm may need to be revised to address
> this issue? At the very least, it would seem that a code audit is in
> order to weed out this particular issue.

Probably related to http://d.puremagic.com/issues/show_bug.cgi?id=6495

This was discussed in http://d.puremagic.com/issues/show_bug.cgi?id=8084

The thing is that realistically, it's going to be a big problem to not be able 
to rely on front returning the same value on every call or not being able to 
rely on the result of front still being around after the call to popFront. 
Ranges such as ByLine are incredibly abnormal, and it's arguably reasonable 
that they must be treated specially by the programmer using them. But that 
could pose a usability problem as well.

So, I don't really know what the right answer is, but I _really_ don't like 
the idea of having to worry about the result of front changing after a call to 
popFront in every single function that ever uses front. In the general case, I 
just don't see how that's tenable. I'd _much_ rather that it be up to the 
programmer using abnormal ranges such as ByLine to use them correctly.

- Jonathan M Davis


More information about the Digitalmars-d mailing list