swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remove list member during a forEach: traversal?


From: Roger M. Burkhart
Subject: Re: remove list member during a forEach: traversal?
Date: Wed, 21 Feb 1996 09:05:16 -0600

>From Nelson's message to Rick Riolo:

> or if you just want to remove everything, call.
>   [aCollection removeAll]
> There's also
>   [aCollection dropAll]
> which also sends drop messages to all the objects. Beware of doing
> this if there are duplicates in the collection.

The messages in the latest release are actually removeAll and deleteAll;
there's no dropAll.  deleteAll both removes and drops each member, but
Nelson's inadvertent use of dropAll indicates that might be a better name.

The problem Nelson notes on duplicates shouldn't be overlooked since if
duplicates are present the deleteAll will typically crash (if you're
lucky) as soon as it hits the second of any member.  There's no good way
to fix this in a general way internally and I wonder if the message really
belongs (I put it in because I'd promised it in response to an earlier
query).

Generally speaking our interfaces avoid defining messages which are
simple combinations of other messages, or use of messages under a particular
traversal algorithm, on the premise that these clutter the underlying
capability while not being able to anticipate many situations in a general
enough way.  forEach: and now removeAll and deleteAll are exceptions to
cover cases that might call for such convenience shorthands.  There's no
inherent problem with removeAll, but deleteAll seems to raise more
questions.  Its function can be duplicated with two messages as follows:

  [aList forEach: M(drop)];
  [aList removeAll];

What I'm saying is that the deleteAll that just showed up might have been
a mistake, at least in name (might make better sense as dropAll) and
perhaps even in basic conception (since the duplicates problem became
apparent only after it showed up).  So feel free to use removeAll but
stay tuned on deleteAll/dropAll.

Roger


reply via email to

[Prev in Thread] Current Thread [Next in Thread]