swarm-support
[Top][All Lists]
Advanced

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

Re: Dropping objects via List


From: Roger M. Burkhart
Subject: Re: Dropping objects via List
Date: Thu, 10 Jul 1997 22:40:45 -0500

Sven Thommesen writes:

> The documentation for List and Collection states that the message
> 
> [ myList removeAll ]
> 
> will empty a list, but if you want to actually delete the objects being
> pointed to by the list, you have to cycle through them and drop them
> individually first.
> 
> Looking at the code, I found that there is an [undocumented ???] method
> 
> [ myList deleteAll ]
> 
> which will not only empty the list of pointers but also drop (remove from
> memory) all objects pointed to by the list.
> 
> Came in really handy in my case!

The trouble is, it doesn't generalize, and so even though there's an old
version of the method that hasn't yet been cleaned out of the code, it's
not documented, not supported, and will be removed from a future version.

A list can reference the same member multiple times, and the drop will

behave very rudely if it tries to drop a member a second time that has
already been dropped.  The method is also redundant with the forEach:
method, which should provide sufficient convenience if you know that you
can get away with dropping members that don't occur multiple times.  The
following code does the same that deleteAll would do:

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

It's a relatively fine call, but generally speaking the libraries don't
provide methods that just combine the effect of a small number of other
methods; such methods add a lot of clutter to the interface and can become
more complicated to document than the occasional coding convenience they
provide.  It is important to document the standard, convenient idioms that
accomplish the same things, however; that needs to be part of the usage
guides/tutorials for each library that nobody's written yet.  It is, of
course, very important that you drop objects referenced by a collection
separate from the collection itself, but dropping them separately is also
needed since the same objects could also be referenced by multiple
collections.

Roger Burkhart
 


                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

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