swarm-support
[Top][All Lists]
Advanced

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

Re: Compiling problem


From: Marcus G. Daniels
Subject: Re: Compiling problem
Date: 14 Feb 1999 17:28:03 -0800

>>>>> "SL" == Sorin Lerner <address@hidden> writes:

SL> `+(ObjectA *)SorinNew:(int)a' example.m:13: warning: also found
SL> `+(ObjectB *)SorinNew:(int)a'

Objective C is a dynamically typed language in which a method's
identity is characterized by its name (and argument keys), and not by
types of its parameters.

If your intent is to add a class that has a default value for some
slot, I recommend implementing object creation in this way:

+ createBegin: aZone
{
  ObjectA *obj = [super createBegin: aZone];

  obj->a = 7;
  return obj;
}

On the other hand, if you want to have the notion of parameterized
object construction, where the parameters can result in a more
structural change than just setting an instance variable, the
Swarm thing to do is to add a create-time setter method which will be used
before createEnd.  The canonical way to parameterize the creation of
objects in Swarm is like this:

  [[[[[Person createBegin: aZone]
       setSuicidalTendencies: YES]
         setMoralFlexibility: 10000000000.0]
           setPersonalityCount: 5]
        createEnd];

Or, if you have no create-time parameters:

  [MyObject create: aZone];

..which has the same effect as:

  [[MyObject createBegin: aZone] createEnd];

I realize these conventions seem peculiar and annoying in
contrast to normal Objective C things, but as we add support for
other languages (e.g. Java), these conventions will follow to a
significant extent. 

As a practical matter, if you try to do object construction in Swarm
without regard to these conventions, it will cause you to lose and
sometimes massively. 

Finally, in Swarm, it is unwise to subclass directly from Object, the
most fundamental class you should probably subclass from in a Swarm
model is CreateDrop.  Typically, SwarmObject is the class folks use.

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