swarm-support
[Top][All Lists]
Advanced

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

Create phase protocol...


From: Barry McMullin
Subject: Create phase protocol...
Date: Tue, 08 Oct 1996 12:35:35 +0000

Hmmmm...

Reading the notes on "Objc - swarm style", my understanding is that,
*in principle* any object of any class imported from the Swarm core
(which is to say *any* class in a swarm app?) *might* have its
pointer (id) changed between its createBegin and its createEnd.

The implication seems to be that if you want to tailor something at
createEnd, you should override the createEnd method with something
like this:

-createEnd {
  id finalSelf;

  // Object initialisation prior to createEnd could be done
  // here, *or* in an overridded createBegin...

  someInstanceVariable = someValue;
  // We can still refer directly to instance variables here,
  // because the self pointer is still valid...

  finalSelf = [super createEnd];

  // Object initialisation for after creatEnd should happen
  // here...

  [finalSelf setSomeOtherInstanceVariableTo: someOtherValue];
  // We *must* use messages here rather than direct refs to
  // instance vars, because the self pointer is no longer
  // valid?

  return finalSelf;
  // MUST return finalSelf rather than (invalid) self....
}

Can any swarm gurus tell me if this is right?

You may wonder why I ask.  The above is my best interpretation of how
to *legitimately* override -createEnd; but this is *not* what is done
in Heatbug.m - there, the overridden -createEnd does not even invoke
the [super createEnd] method *at all*, and simply returns self 
(actually commenting that this is "CRUCIAL!"). This,
at least, in the version of heatbugs I have just looked at - I can't
absolutely guarantee that this is up to date with the recent release.

Now I can see how heatbugs might get away with this (still function),
because the create phase protocol specifies only that the pointer
*may* change at createEnd.  But it seems to me that the *example*
of how to override -createEnd illustrated by Heatbug.m is strictly
defective, and may cause mal-operation at any time in the future as
the swarm core gets modified. Am I right in this, or have I got
the wrong idea completely?  I'd like to know, because I'd like
to be able to override -createEnd in a reliable way, that is 
guaranteed *not* to be broken by future upgrades to the swarm core.

Thanks for any insight,

Barry.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| Barry McMullin, Autonomous Systems Group,  |    address@hidden |
| School of Electronic Engineering,          |  Voice: +353-1-704-5432 |
| Dublin City University, Dublin 9, IRELAND. |  FAX:   +353-1-704-5508 |
| http://www.eeng.dcu.ie/~mcmullin/home.html |                         |
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



reply via email to

[Prev in Thread] Current Thread [Next in Thread]