What’s in a Name?

In order to explore the metadata of an object, addressing it via the player command line, we must go beyond the game world’s normal process of object disambiguation through its vocabulary. Below we discuss the pro’s and con’s of different approaches taken by Proteus in providing an author with a unique handle on an object.

Object Vocabulary

Vocabulary is often very handy. Meta-commands such as <<@show the suit of armor>> provide us with the comfort of language-specific noun phrases. But it does have severe limitations, not the least of which is that vocabulary need not be unique to an object.

 

Objects that share vocabulary, such as a stack of coins, are typically treated as indistinguishable in the game world. This means that the parsing process will treat one coin the same as any other. But from a metadata point of view this need not be the case, and vocabulary fails to provide us with a unique handle by which to grasp the object.

 

Object Symbolic

A more unique handle on the object is provided by its symbolic object name. This is the name an author gives an object so that it can be referenced in source code. Unlike an object’s vocabulary, its symbolic is case-sensitive. For instance, the following definitions refer to two different objects, differentiated only by their case:

 

MyObject: Thing;

 

myObject: Thing;

 

The combination of spelling and case means that an object’s symbolic name is always unique, there can be only one myObject coded in the game. But a symbolic object name is not always available. Dynamically-created and anonymously-defined objects do not have symbolic object names.

 

Object Reference Tag

Proteus provides each object with an object reference tag – a single-quoted string attribute arbitrarily assigned to an object to help identify it. The tag is assigned to every TadsObject class object during the pre-initialization stage of program compilation. Tags are also assigned whenever the TadsObject base class create() message is sent to an object. Lastly, tags are assigned when a TadsObject class object is sent the getObjTagAndSym() message, and no tag is currently assigned to the object.

 

Object reference tags can be used to uniquely identify any TadsObject class object, but are especially useful for addressing dynamically-created and anonymously-defined objects – objects that do not have symbolic object names.

 

Object reference tags are composed of a tads# prefix, followed by a hexadecimal (base-16) number that represents the objRefTagger’s internal objRefCnt at the time the object was tagged. The value is assigned to the object’s objRefTag property.

 

For instance, me might have the following tag: tads#4e0.

Retrieving an Object for a Given Object Reference Tag

Any given String class object can be sent the message getRefTagObj(). The message will return the object corresponding to the object reference tag represented by the string, if one exists, or will return nil if no object is found for the tag. For instance:

 

       ‘tads#4e0’.getRefTagObj()

 

will return the existing TadsObject class object corresponding to the tag, if it exists; otherwise it will return nil.

Retrieving a List of Reference Tag Objects

Because object reference tags are only generated (a) during pre-initialization of program compilation; (b) when TadsObject.created() is invoked on the object; (c) when the message getObjTagAndSym() is sent to the object and the object doesn’t already have an object reference tag, the chance for object reference tag duplication does exist through object instantiation. Proteus attempts to avoid this by sending the message getRefTagObjList() to an object whenever getObjRefTag() is invoked. This method returns a list of all objects that have been assigned a given object reference tag.

 

When getObjRefTag() is invoked, if any other objects are found to possess the same object reference tag the object to which getObjRefTag() was sent is re-tagged, thus providing this object with a unique identifier. Only the object that is sent the message getObjRefTag() will be re-tagged. Any other duplicates returned by the getRefTagObjList() are left untouched.

 

Retrieving an Object’s MetaCommand Reference

For hyperlink construction it can be very handy to build a string that indicates whether the object is to be referred to by its symbolic or its object reference tag. The getMetaCmdReference() method does just this. The string returned is prefixed with either ‘tag’ or ‘sym’ and follows with either the object reference tag or the symbolic for the object.

 

Constructing a command that can be used by aHref() is now simplified:

 

       return aHref(‘@show ‘ + getMetaCmdReference(), getObjTagAndSym());

 

 

This file is part of the TADS 3 Proteus Library Extension

Copyright © 2001-2004 Kevin Forchione. All rights reserved.