Stream mixins?

BCS ao at pathlink.com
Sun Nov 11 09:09:49 PST 2007


Reply to Janice,

> Also - a question. There are functions in the InputStream and
> OutputStream interfaces whose definitions are implementation
> dependent. For example, InputStream.readStringW(). The documentation
> says "The file format is implementation-specific and should not be
> used except as opposite actions to write".
> 
> Now - forgive me for being confused here, but shouldn't an interface
> define what each function must do? Isn't that the whole point of an
> interface? I mean if I published:
> 

It is defined, but something like this: "Write takes the argument an converts 
it to bytes that are pushed into a stream, read takes a stream at a location 
that write started at and read in some bytes and returns the data write was 
given" what is undefined is only the format of the data.

> interface ConfusingInterface
> {
> int f(void[] a);
> }
> but then documented that the content of the input array a is
> implementation-specific, then I have an interface that doesn't mean
> anything!
> 

If it is defined where void[]a should come from it can be useful. Defining 
the format requires either looking stuff down to future change or adding 
all sorts of holes for extension.

> Moreover, the phrase "except as opposite actions to write" make no
> sense, because InputStream has no write functions. The only way I can
> make sense of this instruction is if I assume that every InputStream
> must have a /corresponding/ OutputStream. But if that's true - why not
> just do away with the separate interfaces and just have Stream?
> 

What would you then do for an object that has no write abilities, or no read 
abilities? To be a bit silly, what good is a InputStrem without an OutputStream 
somewhere?





More information about the Digitalmars-d mailing list