[DGD] Inheriting the same program twice

Petter Nyström md1pette at mdstud.chalmers.se
Tue Apr 19 11:47:01 CEST 2005


> Perhaps you could implement X as a seperate object rather than
> something you inherit.
>
> That way A and B could clone up and reference their own copy of X, and
> you could have A and B then call functions in X to retrieve the values
> you want.

Yes. It is either this or having the actual data (mappings in this case) 
private to A and B, and let the functions in X take in the mapping to work 
on as an argument.

The reason for me mailing this to the list was mostly out of curiousity 
what the consensus was on the subject of having one object inherit the 
same program more than once. Is it just plain wrong? Should I then enforce 
this on lib-level by not allowing objects like that to compile? Or does it 
have uses?

> That might work (keeping in mind I don't know the specific application
> you're working on).

I am building a standard MUD, with rooms and all the usual stuff.

The inheritable in question is a sort of command container. It holds a 
mapping where I map command words to the objects handling the command, so 
that when a user types in a command I can find out if there is an objet 
willing to process that command. For characters I want to separate between 
standard commands that are always available and commands made available 
just by the items they are carrying. As items that handle commands are 
received and released by the character, they are registered and 
unregistered as available commands in the command container. (Rooms also 
inherit this program, and offer their commands to all characters present.)

So the problem comes from the fact that I want to have two mappings of 
command words to objects for characters, so that standard commands can be 
masked by commands offered by carried objects.

Cheers,

Jimorie



More information about the DGD mailing list