swarm-support
[Top][All Lists]
Advanced

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

Re: Can a Swarm instance be treated like a SwarmObject instance?


From: William S. Shu
Subject: Re: Can a Swarm instance be treated like a SwarmObject instance?
Date: Thu, 22 Apr 1999 20:29:44 +0100



>
>On Thu, 22 Apr 1999, William S. Shu wrote:
>
>I presume the `createBegin:' fragment below is from the
>SmlSwarm.m.  If so, why are you assigning the pointer
>returned from `[super createBegin: aZone]' (that is,
>`[Swarm createBegin: aZone]') to a SmlObject pointer?
>
>(As I recall) By default the ivars for ObjC objects will
>have a protected access level and hence the compiler is
>correct to warn you about trying to access SmlObject ivars
>from a SmlSwarm method.


>From my understanding of createBegin: this is OK: a 'partially created'
object that allows for instance variables of the current class is provided
from its super.  You could then access it and make modifications
(assignments).  the object becomes 'fully created' when a createEnd message
is later executed (elsewhere).

Besides, the same code fragment works when SwarmObject is in the superclass
hierarchy.

>My apologies if I've mis-interpreted what you are trying to
>do.
What I basically want to do is to have a collection of model swarms
(populations of objects) which could also be treated as objects in other
swarms.  Fortunately or otherwise, the model swarms share properties with
other types of objects (which are not model swarms).  These properties are
ideally put in separate classes which can then be inherited.

Unfortunately, this calls for multiple inheritance -- as some objects are
definitely of SwarmObject class, while others are are model swarms (of Swarm
class).  To circumvent the issue of multiple inheritance (not allowed in
Objective-C), I experimented with duplicating the code.  In doing this,
other problems get raised ... and I seek for assistance from swarm-support!

BTW, trying to circumvent multiple inheritance by using protocols, like so:
        @interface SmlSwarm: Swarm <SwarmObject>
         {...}
         ...
        @end

causes compile-time screams that I have not fully implemented protocol
interfaces, e.g:
        ...
       SmlSwarm.m:375: warning: method definition for `-_I_Using' not found
       SmlSwarm.m:375: warning: class `SmlSwarm' does not fully implement
the
        `SwarmObject' protocol
        ...

I wonder if there is a way of automatically adding such missing protocol
implementations from swarm libraries.  If so, life would be easier!

William.



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