The Importance of $g

In the MUDs, everything is an object. However, referring directly to objects by using object numbers is bad practice because it is prone to errors, and object numbers are not semantically meaningful as variable names. Good programming practice demands a way to refer to objects symbolically, and thus we use $g to do this.

In Blackwood, $g is the symbolic name for object #97 (in the ProgrammingLand MOOseum of Computer Science $g is the logical name for #349), the Game Utilities object, which is a child of the Generic Utilities Package(#79). The object number is different on every MOO, but the idea of $g is the same everywhere.

$g is the standard place for storing utilities relevant to a particular virtual environment, but that are not part of the standard distribution of utilities that come preloaded into the LambdaCore database (e.g. $string_utils, $list_utils, $command_utils, $object_utils, $time_utils, etc.). In general, though, only wizards will create utilities and save them on $g.

As an example, the accessor function

is a verb defined on $g and owned by the wizard, for everyone to use (this is called a 'wizardly' verb).

The Iron Rule: No Object Numbers in Code

More importantly, $g also provides a good way for programmers to create and use symbolic names (and avoid object numbers in code).

The most common way for programmers to use this utilities package is to define a property on $g, and assign it a frequently used object.

For example, if you were creating a member function machine (object #1722, say) for demonstrating how the member function operates, and you will need to refer to the Member Function Room's (#1717) contents in your code, you could write

but a far better method would be to add a member_function_room property to the Game Utilities(#349) object, $g, and then reference the contents of your function room like so:

This works because

How to Add Properties to $g

If you owned $g you could add properties like this

But the wizard owns $g, so you must use the accessor function, like so:

The 'dollarg' Verb to Find $g Properties That Already Exist

Theere are a large number of properties already defined on $g.

Suppose you cannot remember the object number for the Blackwood Town Square. You simply type this verb command to find it:

which returns the following
Candidates on $g:
1. $g.town_square #105
2. $g.town_square_park #106

Contact: slator@cs.ndsu.edu; Modified: 9Nov06