An incompatibity with Streams

Leandro Caniglia caniglia at dm.uba.ar
Fri Aug 24 11:36:55 UTC 2001


The message next:into:startingAt: has two implementations
that are not compatible. In PositionableStream n objects
are transferred into the collection argument. In
StandardFileStream, one or more bytes of the receiver are
combined to match the number of bytes per element in the
collection. For example, if the argument is a Bitmap and the
receiver is a file, then the next 4 bytes of the file are stored
into one word of the bitmap. However, if the receiver is in
memory, then only 1 byte is read and stored in the collection.

I think that this incompatibility should be eliminated.
We all are used to test our code with a stream in memory
instead of a stream in disk, and we could get some
confusing errors for free.

My suggestion is to split these two different behaviors into
two different messages. The current selector #next:into:startingAt:
should be used for methods that transfer objects as they are.
A new method #readBytesInto:startingAt:count: (?) should be
added to do what the current implementation in StandardFileStream
does, that is, combine the proper number of bytes before
storing. Currently #next:into:startingAt: has only some few senders,
so it is easy to replace the intended selector with the appropriate one
in all those places.

/Leandro




More information about the Squeak-dev mailing list