Adding a read primitive to ranges

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun May 3 21:41:10 PDT 2015


On Mon, 04 May 2015 00:07:25 +0000, Freddy wrote:

> Would it be a bad idea to add a read primitive to ranges for streaming?
> ----
> struct ReadRange(T){
>      size_t read(T[] buffer); //and | or T[] read(size_t request);
> 
>      /+ empty,front,popFront,etc +/
> }
> ----

if you want to add such things, i'd say you should model that by 
`std.stdio.File` (`rawRead`, `rawWrite` and other file functions).

i'm using my `streams` module that uses such interfaces for a long time.

can't see why it should be range, though. i introduced "Stream" entity, 
which, like range, can be checked with various traits: isReadableStream, 
isWriteableStream, isSeekableStream and so on. note that stream can be 
range too, that's completely different interfaces.

what is good with taking `std.stdio.File` as a base -- all my stream 
operations immediately usable on standard file objects from Phobos.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150504/595e2d2d/attachment-0001.sig>


More information about the Digitalmars-d mailing list