[phobos] Improvement of stream

Sean Kelly sean at invisibleduck.org
Mon Jul 5 11:00:45 PDT 2010


I haven't decided if it's desirable, but this could be done by copying the range, just like with any other range.  Some logic like this has to be in place anyway, since one could ask for two ranges from the same file object. Each range would either need it's own handle or do some detection and possibly a seek on every operation.  Or an attribute of file objects is that all ranges they provide share the same state. 

Sent from my iPhone

On Jul 5, 2010, at 9:57 AM, Michel Fortin <michel.fortin at michelf.com> wrote:

> 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/
> 
> 
> 
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list