[DGD] Dynamic inheritance

Shevek shevek at btinternet.com
Sat Dec 22 02:25:00 CET 2001


At 01:17 22/12/01 +0200, you wrote:
>I've been thinking of possible solutions for dynamic objects. By dynamic
>objects I mean objects whose type can be altered arbitrarily on the fly, for
>example changing a sword into a door, or even making it be both. One
>possible solution would be to have an object inherit all the possible type
>objects and have flags determine the type(s) of the object, then simply
>cloning everything from it. But I think storing data that might never be
>used is an outrageous waste of resources.

Another alternative for this, I think.
You could always have a daemon style object you pass flags to depending on 
what you want to inherit. Then have the daemon rewrite a template file so 
that the correct inherit lines are inserted, compile the new one, 
reassociate this new object with whatever the old one was associated with 
and destruct the new one. Then the only object that needs to know about the 
inheritance flags is the daemon and the actual inherit lines themselves can 
be stored in a simple text array. This gives you the advantage of being 
able to clone off as many of the new objects as you like to replace 
multiple clones based on the old object.

Just reading that I'm not sure I explained it too well.

Here's another go.

object A requires inheritance alteration.
Make a call to daemon with new inheritance flags.
Daemon read a template file, inserts requested inherit lines, saves and 
compiles the new file to new object B.
Get a list of all things object A and clones are associated with.
Destruct A and clones and reassociate everything with object B and clones 
of object B.

I can see problems with it, but it would make things quite neat.

Cheers,
         Shevek

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



More information about the DGD mailing list