MOO-cows Mailing List Archive


New Server: Interfaces ala Java & COM

One of the major issues with which I've been struggling
while designing the new server is some way to do multiple
inheritence. I've listened to all the arguments floating
around this list about the problems with MI on MOOs. What
I've come up with is a method of adding behaviors (or
interfaces) to an object. The object would still only
have one parent, but also have a list of behaviors.

For example, if I were writing an event notification
method for a room, it is perfectly reasonable to check
whether each item supports the Listener behavior. If the
object implements the Listener behavior, I'll send it a
notification message. The code might look something like
the following:

  for thing in (This:contents())
    if (thing:implements( "Listener" ))
      thing::Listener:ReceiveMessage( SomeMessage );

Naturally, I could also write the code like the

  for thing in (This:contents())
      thing::Listener:ReceiveMessage( SomeMessage );
    catch (E_BEHAVIORNF)
      /*  The object doesn't support the Listener
          behavior, so possibly do something else.

Using this scheme, there is a horrendous amount of string
lookup required. Instead of just doing a string lookup to
find the right method to call, I also have to do a string
lookup to find the behavior. These are potentially expen-
sive. I might replace the string name with a numeric id,
but then the behavior must exist before the code is

Does anyone have any thoughts on the subject?

Jeff Watkins (home) (work)

Home | Subject Index | Thread Index