SCO Visual Tcl Reference Guide
Chapter 2, TclX - the Extended Tcl language

Keyed lists (TCLX)

Keyed lists (TCLX)

Extended Tcl defines a special type of list referred to as ``keyed lists''. These lists provide a structured data type built upon standard Tcl lists. This provides a functionality similar to structs in the C programming language.

A keyed list is a list in which each element contains a key and value pair. These element pairs are stored as lists themselves, where the key is the first element of the list, and the value is the second. The key-value pairs are referred to as ``fields''. Here is an example:

   {{NAME {Frank Zappa}} {JOB {musician and composer}}}
If the variable person contained the above list, then keylget person NAME would return {Frank Zappa}. Executing the command:

keylset person ID 106

would make person contain

   {{ID 106} {NAME {Frank Zappa}} {JOB {musician and composer}}
Fields may contain subfields; period (.) is the separator character. Subfields are actually fields where the value is another keyed list. The next example list has the top level fields ID and NAME, and subfields NAME.FIRST and NAME.LAST:
   {ID 106} {NAME {{FIRST Frank} {LAST Zappa}}}
There is no limit to the recursive depth of subfields, allowing you to build complex data structures.

Keyed lists are constructed and accessed via a number of commands. All keyed list management commands take the name of the variable containing the keyed list as an argument (that is, passed by reference), rather than passing the list directly.

See the manual pages for the following commands: