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

goran.hultgren at bluefish.se goran.hultgren at bluefish.se
Mon Sep 2 14:06:12 UTC 2002


Hi all!

"Andrew C. Greenberg" <werdna at mucow.com> wrote:
> On Monday, September 2, 2002, at 03:39 AM, Richard A. O'Keefe wrote:
> 
> > I also claim that
> >
> >     oldElements copy do: [:each | self remove: each]
> >
> > implemenents precisely the semantics required by the ANSI standard.
> > "each element of oldElements" is visited; the text says nothing about
> > sending any enumeration message to oldElements itself.
> 
> Except on collections where it doesn't: Richard's reasonable code 
> presumes that the collection answers to copy in the manner expected.

According to ANSI I thought objects should answer to copy (see below).

> This code fails, for example, on a LinkedList.

Yes, so I noticed when I tried to use removeAllSuchThat: on a
LinkedList.
But that is a bug in LinkedList (which really is a seriously weird class
btw) since it clearly doesn't implement copy as should be expected
according to ANSI, right? This is a quote from the standard on
Object>>copy :

"Return a new object that must be as similar as possible to the receiver
in its initial state and
behavior. Any operation that changes the state of the new object should
not as a side-effect
change the state or behavior of the receiver. Similarly, any change to
the receiver should not as a
side-effect change the new object.
If the receiver is an identity object, return the receiver."

regards, Göran

PS. All this talk about the ANSI standard makes my head hurt... Let's
get back to some good old Squeaking. ;-) DS



More information about the Squeak-dev mailing list