The standard does *not* support - a removeAll: a - [was: Re: [BUG] Collection>>removeAll:]

Lex Spoon lex at cc.gatech.edu
Thu Sep 5 00:11:57 UTC 2002


goran.hultgren at bluefish.se wrote:

> > Notwithstanding that, I am sensible to Richard's suggestion that when 
> > it is practicable to catch a circumstance that misbehaves, we shouldn't 
> > do so silently.  I am for adding the assert.
> 
> I can understand your points, but what about fixing the specific case by
> calling removeAll instead?

This kind of silent fix can lead to trouble later when you make things
slightly more complicated.  For example, suppose you looked at the
following code, which worked:

	a removeAll: a

and then changed it to this, which doesn't work:

	a do: [ :each | a remove: each ]


It seems better to make it an error.  This situation is easily worked
around by using copies or by using removeAll.


-Lex


PS -- an alternative approach to this mess might be to mark a collection
while it is being iterated, and for all modification commands to check
whether the mark is turned on.



More information about the Squeak-dev mailing list