swarm-support
[Top][All Lists]
Advanced

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

What classes are there in Swarm and where do "object creators" come fro


From: Paul Johnson
Subject: What classes are there in Swarm and where do "object creators" come from?
Date: Thu, 17 Feb 2000 10:38:36 -0600

I was teaching yesterday about declarations in swarm and something got
me confused.  The issue is about protocols, and what's a class in swarm,
and how do users know what "classes" in swarm can create objects?  And,
furthermore, how much compile time error checking do you buy by naming
something statically or declaring a protocol. 


First, does every Protocol have a corresponding "object creator" of the
same name?  I say "object creator" because I know that, in the swarm
libraries, there are lots of things that we treat like classes, but they
are not really classes any more. When the user does

    list=[List create: self];

it makes a list object.  But in the Swarm sourcecode, there is no longer
any class called List, and that the functionality of a list is in a
class called List_any.  


If I understand the swarm setup, the idea is that the user goes by the
Protocol list (the sacred bond between programmer and library, I think
Marcus called it that once) in order to see what actions an object can
execute.  And the actual implementation of these actions is hidden in
the swarm libraries, it is done by classes that have names that can be
completely different than the name of the Protocol.  But there is
something in the middle, between the protocol declarations and the
differently-named classes, that is gluing them together.  What is that?

On a related note, can I ask something about protocols and compile-time
checking?

Suppose I have a protocol I made up, call it <MovieActor>.  And I have a
class that adopts that protocol, RuggedLeadingMan.  Suppose that
RuggedLeadingMan has methods that are not in MovieActor.  If I declare
an instance as

  RuggedLeadingMan * sylvester;

then the compiler does not complain to me after I've done
   sylvester= [[RuggedLeadingMan createBegin: self] createEnd];
and then I tell sylvester to do something that is not listed in the
protocol, but it is defined in RuggedLeadingMan.

However, if I declare sylvester this way,

  id <MovieActor> sylvester;
and create the instance the same way as before, and then tell the agent
to do something not in the protocol, then the compiler issues a warning
that the action is not in the protocol.  With swarm's Makefile.common
using -Werror, this stops the compilation.  Is this right? I think it is
what I experience.  I can remove the Werror flag, and the compile
completes.


Incidentally, I tried to create a static object of type List_any, i.e.,
    List * list;
but that appears just to be a typo, in the eyes of the compiler.  Hence,
the "List" thing we are calling to make lists is not a class, as far as
the interface goes, anyway. And 

    List_any * list;

makes the compiler say swarm won't allow static allocations like that.  



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