OrderedCollections not supported in WriteStream.

nice ncellier at ifrance.com
Sat Feb 17 09:53:54 UTC 2007


Ralph Boland a écrit :
> 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
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 
Hello Ralph,

This is a possible solution.
Dictionary for example grow when sent at:put: with a new key.
But this is questionnable with OrderedCollection, because:
- you need to allocate eventually a lot of memory
- you also add a bunch of nil

Matlab did and main consequence is to delay bug finding.
Most code will expect an outOfBounds error.

So I would say, please don't.

If we want growth, we'd better use explicit messages for that, with 
generallity larger than just OrderedCollection.
And if only for making WriteStream on: OrderedCollection new work, there 
are other solutions with less side effects.
Only my personal feeling...

Nicolas




More information about the Squeak-dev mailing list