stream interfaces - with ranges

Martin Nowak dawg at dawgfoto.de
Mon May 21 16:32:09 PDT 2012


> Well, because that's what i/o buffers are :)  There isn't an OS  
> primitive that reads a file descriptor into an e.g. linked list.   
> Anything other than a slice would go through a translation.
>
It's a pity that iovec and T[] have switch length/ptr fields.
Otherwise one could directly map read(ubyte[] bufs...) to libc.readv.

It did wrote a buffered range that uses a linked list to promote an
input range to a forward range. This is somewhat similar to lazy
ByteStrings in haskell.
There were some issue with reference counting and the implicit copy
in foreach loops but other than that it's fairly useful.

https://gist.github.com/1257196

The trouble with block-wise primitives (T[] input ranges) like byChunk is
that they make common things like parsing very difficult because the client
has to account for buffer wraps. Things like double buffering or a  
ringbuffer
would help for this.

martin


More information about the Digitalmars-d mailing list