On 2010-01-01 09:47:58 -0500, Andrei Alexandrescu <[email protected]> said:

Upon more thinking, I'm leaning the other way. ~= is a quirk of arrays motivated by practical necessity. I don't want to propagate that quirk into ranges. The best output range is one that works properly when passed by value.

I agree and disagree. I wasn't proposing that ranges support ~=, and I don't thing it'd be a good idea, so I agree with you here.

But I still believe output ranges should behave like arrays. I was proposing that you model output ranges after buffers. A stream then becomes a buffer of infinite length.

Look at this example:

        char[10] buffer;
        char[] remainingSpace = buffer[];
        while (!remainingSpace.empty)
                remainingSpace.put(getc());

        // now buffer is full
        writeln(buffer);

Now rename "remainingSpace" for "outputStream" and it works fine, except for two things: "empty" sounds strange, and an output stream is never empty of remaining space: it's infinite length.

But conceptually, a buffer and a stream are almost the same, one having finite capacity while the other is infinite.


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to