Transience of .front in input vs. forward ranges

monarch_dodra monarchdodra at gmail.com
Sun Nov 4 09:53:06 PST 2012


On Sunday, 4 November 2012 at 17:38:07 UTC, Andrei Alexandrescu 
wrote:
> Back to a simpler solution: what's wrong with adding 
> alternative APIs for certain input ranges? We have byLine, 
> byChunk, byChunkAsync. We may as well add eachLine, eachChunk, 
> eachChunkAsync and let the documentation explain the 
> differences.
>
>
> Andrei

Yes, please! (<nitpick>Although I don't necessarily agree with 
the naming</nitpick>).

I think we should go with transient ranges the same way we went 
with "non-size_t index" ranges. Acknowledge that they exist, but 
not guarantee their support when passed to Phobos algorithms.

byLine is a perfect example of this: You can use it all you want 
in a for loop, but pass it "copy" or "array" at your own risk.

At that point, all we do is "tag" byLine as "Warning: 
Transient.", and call it a day. Not as perfectly safe as we'd 
want, but good enough, IMO. We then offer "eachLine", which isn't 
transient, and everyone is happy.


More information about the Digitalmars-d mailing list