mudlib: base
topic: rambling thoughts on what should be.
last modified: 1992/07/22, John Garnett

Ideas on a standard base object (/std/obj.c):

Contains code for set() and query().  #includes <attributes.h> to
get #defines for the various property names.  This ensures that
mispelled property names will be caught at compile time.

E.g.

#define SHORT "short"

set(SHORT,"an umbrella");

Attribute security is not a primary concern but we might want to think 
about making provisions for it.  Should be fairly trivial to add some
rudimentary system of permissions on what/who can change properties of
objects.  Each property of an object can have an associated access attribute.
E.g. some attributes should only be settable by the object having the
attribute.  Would be nice to come up with a general attributes permissions
scheme.  E.g., it would be nice to allow a group of objects to
belong to some permissions group that let any object in the group modify
attributes in other objects in the group (for example, the group might
consist of all objects in a given domain).  Hmmm, something like
obj->chmod(SHORT, permissions).

It seems important to me to keep a consistent model for dealing with
attributes.  Even if it requires sacrificing a little performance.
For example, I think it may be worth it to make CONTAINS (i.e. all_inventory)
into an attribute of an object.  Granted, it might be unreasonably slower to do
this in the mudlib rather than the driver (until faster hardware inevitably
becomes available).  Thus, we could consider an interim solution of
'computed' attributes.  I envision being able to do something like this
to get the inventory of an object.

object *inv;

inv = obj->query(CONTAINS);

The idea is that query(CONTAINS) actually simply calls
all_inventory(this_object()).  This preserves OOP principles (OOPP).
This idea also helps decouple LPC objects from the driver.  Ideally,
I'd like to be able to code with the illusion that the driver only
provides support for compiling objects, message passing, call_outs,
and heartbeats (thus we use a "remove" message instead of destruct(),
"move" instead of move_object(), a "query(CONTAINS)" message instead
of all_inventory(), etc), and efuns that don't provide information
that could be considered attributes of objects.  Even uid, euid
could be handled as attributes of objects (handled in the mudlib) if
we had a proper permissions system for attributes.

Computed attributes could be useful for providing special case
behavior as well.  For example, we could make the TEXT attribute of
a magic book be a computed attribute so that when the book is read a genie
pops into the room and grants you three wishes or whatever (in this
case the code that does the computing is LPC code and not a driver
efun).

To summarize:

1) Obj.c would provide support for set(ATTR,value) and query(ATTR).

2) Each ATTR should eventually have an associated permissions attribute
   (determining who can modify the attribute).
   (e.g. obj->chmod(ATTR,permissions).

3) Each ATTR will have an associated type (e.g. literal, computed, boolean).
   'Literal' corresponds to the traditional attribute having an integer
   or string value (e.g.) that stays constant until changed via a set()
   call.  'Computed' refers to those attributes which cause either an
   efun or LPC code to be called in order to compute the attribute (and
   perhaps do some side effects such as producing a genie when a magic
   book is read or whatever).  'Boolean' attributes are those that have
   either a true or false value.  Of course booleans could be handled
   via the literal case but we may wish to handle them separately for
   efficiency of storage reasons. 

   An object should be able to designate that a certain (normally literal)
   attribute (e.g. TEXT or LONG) is to be computed.  Hmm, if we allowed
   builtin computed attributes to be overridden, then objects could lie about
   what they contain :).

Implementation:

First of all, all standard attribute names should be #define'd to
integers.


#define OPEN   0
#define LIVING 1
#define SHORT  2
#define LONG   3

string bool_attrs = "";
string bool_computed = "";

mixed query(mixed attr)
{
	if (intp(attr)) {
	} else {
	}
}
