swarm-support
[Top][All Lists]
Advanced

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

Re: Implementing Frequency Lists.


From: Paul E. Johnson
Subject: Re: Implementing Frequency Lists.
Date: Tue, 30 Mar 1999 11:32:22 -0600

"William S. Shu" wrote:

> Thanks.  But this will not do, as I do not know N (the maximum no. instances
> I need).  The number of instances can be arbitrarily many, depending on
> available memory!  Also, I think your "Frequency_Indicator" is just like my
> "FrequencyCell".
Hmm. Interesting. I guess instead of Array you need a "OrderedSet" or
"Map" object holding the frequency indicators.  I wish there was much
more documentation and examples on these collection types.  As long as
you have some numerical index for each object, the compare function
could use it to keep track of the items.  I don't have code examples off
hand. If you look in the swarm-support mailing list archives, you will
find talk of sets and maps. I recall one relatively detailed discussion
about three months ago.  It is one of the things I've been meaning to
look into.

Perhaps can write up a FAQ entry for me about it once you have some
working examples.

> I was hoping for an indexing facility -- or an adaptation thereof -- in
> swarm which would permit me index on a field (variable) in a class/object.
(I think thats the MAP protocol or Ordered Set, I'm not sure which is
best for your case. As I recall, the Map type allows you to grab objects
by giving a key, but the Ordered Set uses some value (possibly returned
by a "getYourValue" method) to order objects as they are inserted.)

I think a revamp and enhancement of the collections library has been on
the TODO list for a long time.  At Swarmfest last weekend, I met a
person who suggested we might just take list items from other libraries,
such a glib or GNUstep.  I'm wishing somebody with lots of free time
would tell me how I could do that. I have a feeling its not so simple as
adding #import glib.h at the top of a file.

> I hope you do not mean my tinkering with the class "SwarmObject"! (*g*)  I
> assume the alternative interpretation -- that of having a class containing a
> list object:
>     I have have actually implemented an object with a list variable inside.
> but that means developing a parallel set of methods already implemented by
> List protocol; I also loose on the generality of List!
When You create a list in Swarm, it automatically has access to all the
methods of the List protocol.  Same with an instance of Array, Map, etc.
I have never gotten a completely straight explanation about "what class
does this object belong to".  It seems to me that you ought to think of 
a List object as an instance of a class List and its methods are the
ones listed in the List protocol. When I started in swarm, many of these
things were written as classes, and I didn't have any trouble
understanding then. But most everything is now offered as a protocol for
interface design reasons, but you can still think of them as classes.  I
asked about this a while ago and was assured that when you use the
factory object like List to create new lists, you might as well think of
it as a class because this new list inherits all methods of the List
protocol and every other protocol that List inherits from. Clear as mud?
Why is it a protocol and not a class? Protocols allow "mixing and
matching" of capabilities. You could write a new class that brings in
many protocols and thus inherits many capabilities. Objective C does not
allow multiple inheritance, but it does allow adoption of multiple
protocols, which seems like the same thing to me.

I think I will try to re phrase our question and ask it again in this
list if I don't figure it out soon.
 
> The above notwithstanding, I still do not understand why I can create a List
> object and do not get complaints for not defining the methods.  (From
> Objective-C definition of protocols, I should define methods for protocols I
> use!)
Well, your thing from list=[List create: self] automatically has access
to the List protocol.  "create" packs a lot of power
> 
> Furthermore, List objects necessarily belong to some class:  why can I not
> subclass from that class?  (Is this a swarm-specific issue?)
Swarm Specific limit on subclassing from lists due to complexity of
object structures.
If you look in the swarm docs on this, they say that you cannot
subclass, the thing to do is create a "wrapper" object in your code that
has a list inside it and then you write special methods in there so
supplement the functionality. I'm not exactly sure which special
functionality you need, but here is an example of one I've thought
about.  I have a bunch of C arrays. I want added to a Array class
object's slots. But Array only wants to have id objects.  So I create a
subclass of SwarmObject, and in there I create the C array. Then I have
methods in that class like "getValueCoordinate: (int) x" and such.  SO
this new object of type SwarmObject can then be put in position in the
Array object, and methods of this new "wrapper" class can take in values
of the C array and pass them back out. 
> 


-- 
Paul E. Johnson                         email: address@hidden
Dept. of Political Science              http://lark.cc.ukans.edu/~pauljohn
University of Kansas                    Office: (785) 864-9086
Lawrence, Kansas 66045                  FAX: (785) 864-5700

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