www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: Streaming library

Andrei Alexandrescu Wrote:

 On 10/13/10 16:32 CDT, Steven Schveighoffer wrote:
 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.

Except the parameters are all inputs -- there is no casting from void[]. -Steve
Oct 13 2010