Transience of .front in input vs. forward ranges

Jonathan M Davis jmdavisProg at gmx.com
Sat Nov 3 18:02:27 PDT 2012


On Saturday, November 03, 2012 16:21:19 H. S. Teoh wrote:
> I wish Andrei would give some input as to how we should proceed with
> this. I do consider this a major issue with ranges, because for
> efficiency reasons I often write ranges that have transient .front
> values, and they can lead to subtle bugs with the current implementation
> of std.algorithm. It would be good to settle on this issue one way or
> another. I'd be happy even if the decision is to say that transient
> ranges are invalid and shouldn't be considered "real" ranges. Anything
> is better than the current nebulous state of things which only leads to
> subtle bugs for the unwary.

I think that you're the only person that I've ever heard of who created a 
front that was transient outside of std.stdio. But who knows what people 
outside of this newsgroup are doing.

Andrei seems to think that algorithms should consider input ranges' fronts to 
be transient, and that forward ranges and greater shouldn't have transient 
fronts. And I don't think that he's said much about it after that (probably 
mostly because he was out of town and unable to communicate on the newsgroup 
much for a while). However, I think that he's the only one in this thread who 
had come to that conclusion. Most of the rest of us agree that transience 
isn't necessarily related to the type of range at all. And I think that most 
everyone has considered ranges like ByLine and ByChunk to be bizarre and 
abnormal and not something that normal algorithms need to worry about (and if 
anything that ByLine and ByChunk should be changed to be non-transient or to 
not be ranges at all).

If we're going to support transient fronts, then we need a solid plan for 
doing so. Even if it's the case that we're ultimately going to go with input 
ranges' fronts being considered transient, and all other ranges' fronts being 
considered non-transient, we need that to be clear and be made explicitly 
clear in the docs. It's definitely not how things are treated right now.

- Jonathan M Davis


More information about the Digitalmars-d mailing list