swarm-support
[Top][All Lists]
Advanced

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

subclassing a list


From: glen e. p. ropella
Subject: subclassing a list
Date: Fri, 10 Oct 1997 08:43:12 -0600

Timothy Jares writes:
 > I'm trying to add a simple  method to the list class to insert my objects
 > in ascending order.  I'm sure this should be a simple task but strange
 > things are happening and I'm not sure what to do.  Ideally, I would
 > only like to add a single method which utilizes an index to place the
 > entry at the proper place in the list.  If I understand everything
 > correctly, the documentation suggests that I create a new class,
 > e.g., SortList, that adds the method and simply passes through
 > other messages to the List class.  

Are you trying to subclass from the List object?  Because that
won't work.  Our collections library uses the object customization
described in the docs, meaning that the class you end up with
after setting all the options might not be the class you started
with.  So, subclassing from List isn't possible because there
really isn't a List class.

You could try to subclass from List_linked or List_mlinks, if you are
interested in navigating the guts of the collections library.  (See:
http://www.santafe.edu/projects/swarm/archive/list-archive.9606/0031.html
and the subsequent thread)

But the recommended course is to create a new class (which you may
be claiming you've done...) subclassed from SwarmObject that contains
a List IVar, then you can manipulate that list through that delegatory
object.

 > Does anyone have any examples of this?  I have tried to do this by
 > adding my method and and "shell" methods for begin, getCount,
 > etc. that simply forward on messages to my list instance.  
 > 
 > If a code fragment of what I've done would be helpful, I'll include
 > it later.

If this is what you've done, then you should send the class to the
list, because there are a number of ways you might do that.  It might
also be helpful to find out what's actually gone wrong... compiler
error, runtime error,etc.

glen
-- 
{glen e. p. ropella <address@hidden> |  Send lawyers, guns, and money!  }
{Hive Drone, SFI Swarm Project         |            Hail Eris!            }
{http://www.trail.com/~gepr/home.html  |               =><=               }

                  ==================================
   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]