Transient ranges

Joseph Rushton Wakeling via Digitalmars-d digitalmars-d at puremagic.com
Mon May 30 05:21:44 PDT 2016


On Sunday, 29 May 2016 at 17:29:35 UTC, Steven Schveighoffer 
wrote:
> This doesn't help at all. I can still make a "transient" range 
> with all three range primitives.
>
> There seems to be a misunderstanding about what a transient 
> range is.
>
> byLine is a transient range that requires the front element be 
> cacheable (I have to build the line somewhere, and reusing that 
> buffer provides performance). Shoehorning into a popFront-only 
> style "range" does not solve the problem. Not only that, but 
> now I would have to cache BOTH the front element and the next 
> one.

Ack, yea, I think see the issue.  It's

     auto a = transientRange.front;
     transientRange.popFront() // <=== now a has changed

Even if you go with the only-2-primitives one, you'd have the 
same problem:

     auto a = transientRange.front;
     auto b = transientRange.front;   // <=== now a has changed

My "empty + front only" idea was more inspired by the case e.g. 
where the range is wrapping some truly-random signal (like the 
current observed value of atmospheric noise, for example), it 
clearly doesn't solve this case.


More information about the Digitalmars-d mailing list