Streaming library
Denis Koroskin
2korden at gmail.com
Wed Oct 13 15:06:28 PDT 2010
On Thu, 14 Oct 2010 01:57:56 +0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> On 10/13/10 16:32 CDT, Steven Schveighoffer wrote:
> [snip]
>
> All good points.
>
>>> interface InputStream
>>> {
>>> // reads up to buffer.length bytes from a stream
>>> // returns number of bytes read
>>> // throws on error
>>> size_t read(ubyte[] buffer);
>>>
>>> // reads from current position
>>> AsyncReadRequest readAsync(ubyte[] buffer, Mailbox* mailbox = null);
>>> }
>>
>> I'd say void[] is better here, since you aren't creating the buffer,
>> you're accepting it. Using ubyte makes for awkward casts when you are
>> reading binary data into specific structures.
>>
>> ditto for OutputStream.
>
> Well casting from void[] is equally awkward isn't it? I'm still
> undecided on which is better.
>
>
> Andrei
I prefer ubyte[] because that helps GC (void arrays are scanned for
pointers).
Besides, ubyte[] is just a sequence of bytes and that's exactly what's
being read from a stream.
More information about the Digitalmars-d
mailing list