Examining an Object’s Structure
So far we have explored the treasures of the global symbol table; the various means of addressing an object through the use of its vocabulary, its symbolic name, or its object reference tag; and the messages involved in exploring an object’s “family” lineage, its ancestors, parents, descendants, and children.
Now it’s time to explore the structure of the object itself. Proteus takes advantage of many of the TADS 3 reflection features in order to give us a glimpse into an object’s structure during runtime.
What
Do We Mean
by Structure?
The getInherStrucList() message can be sent to any Object class object. It will return a list consisting of the following elements:
[[object [
directlyDefinedPropertyList ]], …]
The method iterates over the entire inheritance hierarchy of the object, and is capable of producing a prodigious list, indeed. The following is an example of the partial list produced from me.getInherStrucList():
[
[me, [&location, &pendingCommand, &antecedentTable,
&objRefTag]],
[Actor, [&name, &itNom, &theNamePossNoun,
&itIsContraction, &conjugateRegularVerb, &itPossNoun,
&pronounSelector, &verbEndingS, &itVerb, &itReflexive,
&verbEndingEs, &theName, &thatObj, &verbWas, &thatNom,
&travelerName, &aNameObj, &verbToBe, &verbEndingIes,
&theNamePossAdj, &itPossAdj, &itIs, &theNameObj, &aName,
&conjugationSelector, &verbToHave, &itObj, &objRefTag]],
. . .
]
The full list would continue for several pages.
The method takes a variable argument list. The valid signatures are:
- getInherStrucList()
- getInherStrucList(suppress)
- getInherStrucList(func)
- getInherStrucList(func, suppress)
If suppress is true then object / property list sub-elements are not added to the list when the property list is empty.
The callback function func should be of the form func(obj, prop) that returns either true or nil. If the function returns true the object / property sub-element is added to the list, otherwise it is not.
Structure Classes
The message Actor.getInherSuperclassList() produces a list consisting of some 12 objects.
- me
- Actor
- 4b0
- Thing
- 553
- 4b3
- VocabObject
- 330
- TadsObject
- Object
- Schedulable
- Traveler
It can be seen from this list that none of the objects occur more than once in the structure list. Even though the method iterates down and across the entire inheritance hierarchy, only unique objects are added to the list in the order that they are encountered in the traversal. The objects appearing as numbers