[DGD]Sharing variables between cloned objects.

Kris Van Hees aedil at alchar.org
Fri May 4 00:55:35 CEST 2001


Not quite...  DGD implements a system that makes a copy of local references to
'foreign' arrays and mappings at the end of an execution chain.  So, when your
object would call upon the central object to get a reference to  the  mapping,
it would only be a true reference for that particular chain of execution.   At
the next execution chain that touches the object, the reference will  actually
be to a local copy of the mapping, rather than the central one.

You'd be better off to use your initial idea of keeping the mapping in its own
separate object, and to query it from the other objects.

	Kris

On Thu, May 03, 2001 at 05:15:27PM +0800, John West McKenna wrote:
> Thomas Annandale writes:
> 
> >  Specifically, I want a mapping that is initialized with data once and
> >then left alone for the rest of its life.  A cloneable object will use
> >this mapping frequently.  I don't want every clone to have its own copy of
> >the mapping, as that seems like a big memory waste.  The only way I can
> >think to do this now is to make a separate object to store the mapping 
> >that all of the clones query whenever they need it.  Is there a better
> >way?
> 
> I've been doing more Lua coding than LPC lately, so I might be confused.
> A variable of type "mapping" isn't the mapping itself - it's just a
> reference to it.  You can have multiple variables referring to the same
> mapping.
> 
> I'd expect the easiest way to do this is have a separate object that
> creates and fills the mapping, and also has a function to return a
> reference to it.  Your objects can then query this when they are created,
> and store it in their own private variables.
> 
> That way you don't have many copies of the data, and you don't have the
> overhead of the query call every time you want to use it.
> 
> If you really don't want an extra object, you could have the blueprint for
> the clonable object create the mapping, and have the clones query it for
> their references.  But that's rather ugly.
> 
> John
> 
> List config page:  http://list.imaginary.com/mailman/listinfo/dgd

-- 
Software Developer & Creator of Worlds

List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list