[RFC] I/O and Buffer Range

Dmitry Olshansky dmitry.olsh at gmail.com
Sun Jan 5 05:29:54 PST 2014


05-Jan-2014 15:08, Jason White пишет:
> On Sunday, 5 January 2014 at 09:33:46 UTC, Dmitry Olshansky wrote:
>> As an advice I'd suggest to drop the 'Data' part in
>> writeData/readData. It's obvious and adds no extra value.
>
> You're right, but it avoids a name clash if it's composed with text
> writing. "write" would be used for text and "writeData" would be used
> for raw data. std.stdio.File uses the names rawRead/rawWrite to avoid
> that problem (which, I suppose, are more appropriate names).
>

I my view text implies something like:

void write(const(char)[]);
size_t read(char[]);

And binary would be:

void write(const(ubyte)[]);
size_t read(ubyte[]);

Should not clash.

>> Will poke around. I like this (I mean composition):
>> https://github.com/jasonwhite/io/blob/master/src/io/stdio.d#L17
>
> Yeah, the idea is to separate buffering, text, and locking operations so
> that they can be composed with any other type of stream (e.g., files,
> in-memory arrays, or sockets).

In-memory array IMHO better not pretend to be a stream. This kind of 
wrapping goes in the wrong direction (losing capabilities). Instead 
wrapping a stream and/or array as a buffer range proved to me to be more 
natural (extending capabilities).

>Currently, std.stdio has all three of
> those facets rolled into one.

Locking though is a province of shared and may need a bit more thought.

-- 
Dmitry Olshansky


More information about the Digitalmars-d mailing list