[DGD]Sharing variables between cloned objects.

Felix A. Croes felix at dworkin.nl
Fri May 4 00:54:04 CEST 2001


John "West" McKenna <john at ucc.gu.uwa.edu.au> 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.

This will only work as long as the current LPC thread lasts.  As soon
as it finishes, those private references become private copies, with
each object its own copy.

Regards,
Dworkin

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



More information about the DGD mailing list