Special Topics: Objects

Objects are the C structures and their fields that have been registered so that they are accessible from within the Tcl shell. Most, but not all, structures used in Lens are accessible, although many are write-protected. The empty name, "" or {}, always refers to the current network. No variables or structures are accessible unless they can be reached from the current network, but the current network does have links to all example sets and all other networks via the root object.

The object structure can be traversed with the Object Viewer. Structures and fields can also be displayed in text with the getObject command and the values of basic fields (such as integers, reals, strings, flags, masks, and Tcl commands) can be set using setObject.

An object name or path is a list of fields separated by periods, as in trainingSet.currentExample.numEvents. Structures can also contain one- and two-dimensional arrays. The preferred method of indexing arrays is with the index in parentheses, as in group(3). Two-dimensional arrays should be indexed with a single set of parentheses and a comma separating the indices, as in group(4).ext.myarray(3,7). These indexing methods conform to Tcl style. They can also be indexed with two parentheses in succession, as in group(4).ext.myarray(3)(7).

C style uses square brackets rather than parentheses for array indices. This is also possible in Lens but can cause problems since the interpreter will attempt to do command substitution on anything in square brackets and this must be counteracted.

As a shortcut, you can refer to networks, example sets, or groups and units in the current network directly by name. Thus, if the third group were named "hidden", you could refer to its size with either group(2).numUnits or hidden.numUnits. You should not use periods in the names of objects that you might want to reference directly as it will cause problems.

Units can be referred to directly with the group name followed by a colon and the unit number, as in "hidden:3".

To understand the meaning of particular objects, see the section on The Structures. One object worth mentioning is the root field in each network. This is a structure that contains arrays of all of the networks and example sets currently loaded and the number of each. This allows the user to access networks and example sets other than those currently in use.

If there is no current network, then the root structure is the head of the object tree. In this case the number of example sets is numExampleSets. But if there is a network in use, root.numExampleSets is the path to the number of example sets. However, the root structure contains a link to itself, so root.numExampleSets can be used to access the number of example sets whether or not there is a current network.

Douglas Rohde
Last modified: Wed Apr 19 20:02:53 EDT 2000