swarm-support
[Top][All Lists]
Advanced

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

Re: Copy


From: Roger M. Burkhart
Subject: Re: Copy
Date: Thu, 5 Dec 1996 17:09:12 -0600

Rick Riolo asks about copy:

> re inherited copy:
> Roger says 
>    > There is no standard copy message inherited for all objects
> I guess I am confused about why one can go up the hierarchy
> using the go-up button in probes and eventually get to
> the object class, which (in the probe) seems to have a copy method
> (along with init,free,shallowCopy, and a bunch more methods)
> which I can click on and then get a reference to a copy of the probed
> Heatbug which I can then drag over and add to the heatbugs list.

Yes, there is a copy up there in the runtime system's version of
the top-level Object class.  We still inherit from Object but since we
don't follow its particular model of object creation or allocation it's
not suggested that you use its messages to create SwarmObjects.  But the
messages are still there all the same, and do still work, but not
necessarily correctly for a particular subclass.  In particular, the
top-level copy message does a shallow copy (local instance variables only)
without any of the Zone apparatus that we've still got major plans for in
Swarm (such as, to clean up storage for an entire run of an experiment
when going on to run another one).  Even though there is a version of copy
inherited from Object, if you really want a copy message it's recommended
that you implement your own version of a copy: method that accepts the
Zone argument.

> As I said in my first message, I've not used the copy method before 
> but I just assumed it would be there to make a copy of any object inheriting 
> from SwarmObject.
> Am I wrong about that?  Why does it work in Heatbugs?

It wasn't intended to be used on objects inheriting from SwarmObject, but it
does work since it's a shallow copy into newly malloc'd space, and that's
all that a heatbug needs.  (Come to think of it, we even use the copy
method from Object when demonstrating probe capabilities, so I've seen it
work myself.)

Since we're not following the creation/allocation conventions of Object,
we could block access to those methods from subclasses of SwarmObject,
and then only the methods that we actually provided in SwarmObject, or that
you provided in your own subclass, would be available.  Perhaps we should
consider doing this to avoid future confusion.

> thanks for clearing this up for me (and maybe others).

Thanks for helping clear this up for me, too!

Roger


reply via email to

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