[phobos] Improvement of stream
Michel Fortin
michel.fortin at michelf.com
Mon Jul 5 09:57:05 PDT 2010
Le 2010-07-05 à 12:23, Andrei Alexandrescu a écrit :
> On 07/05/2010 11:14 AM, Michel Fortin wrote:
>> But I have to admit the ability of a range to seek outside of the range's range (like rewinding) seems a little odd. It does fit better with a 'stream' concept.
>
> Ranges are streams!
I'm not contesting that (at this time). What I meant is that allowing a range to seek beyond its bounds looks counter nature to me. If it was called a stream it wouldn't be so bad. It's mostly a naming thing.
For instance, let's say I have a file with this content:
[0,1,2,3,4,5,6,7,8,9];
I call popFront 5 times, so the content of the range conceptually becomes this:
[5,6,7,8,9];
Then I call a function, say seek(2), to return to the third element. Does this add back elements in my range?
[2,3,4,5,6,7,8,9]
Adding back elements to a range seems quite un-range-like to me. Seeking to a position relative to the first element in the "container" (the file) would be even more so.
Now call it a stream and it looks more natural to do these operations. But perhaps it's only me.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the phobos
mailing list