OrderedCollections not supported in WriteStream.

Ralph Boland rpboland at gmail.com
Thu Feb 15 17:25:24 UTC 2007


In an earlier post it was noted that WriteStream does not support having its

collection instance variable being an instance of OrderedCollection;
the Problem being that OrderedCollection does not support:

       #at:index put: object

where the index is beyond the lastIndex instance variable
of the orderedCollection object.

I suggest that if the value of index  is one beyond  the value of lastIndex
then
the orderCollection object do an add operation and otherwise behave as
before.

This would fix the problem with WriteStream
but I suppose this violates some principle somewhere.

For me the complaint is that now you have the WriteStream instance
managing the size of its collection and if its collection is an instance of
OrderedCollection the collection is also managing its own size.

For the record:
What are the reasons that WriteStream was not designed
to use OrderedCollection as the class of its
(then internally instanciated and private) collection instance variable
anyway?
This would have made the implementation of WriteStream MUCH simpler.

One could argue that this would prevent  the collection being some kind of
growable
linked list structure.  But since WriteStream already does a complete copy
every
time it decides the collection is too small this doesn't seem very important
to me.

Of course, since the user passes the initial collection to the WriteStream
object,
he also has access to the collection which he would then lose.
But it is not clear to me why the user should have direct access to the
collection at all.
Of course, for PositionalStream objects, the user would still need
to pass in a collection object but WriteStream could override this behavior.

The biggest problem I see with modifying WriteStream to work this way is
that currently the user determines the class of the object returned by the
contents method of WriteStream.  With this change the class of the object
returned would be decided by WriteStream.

If WriteStream were modified to work this way would anything in Squeak
break?
Of course somewhere some squeak user would get burned but since I think
such users have written BAD code I am not too sympathetic.

Reasons why the whole idea is just plain bad are perfectly welcome.
(And who's going to stop you from pointing them out anyway.)


Ralph Boland
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20070215/f51a3a7c/attachment.htm


More information about the Squeak-dev mailing list