if 0 { Tcl has no struct or record facility. We can approximate them with keyed lists or the like, but they just aren't as compact or usable as a simple record. Thus was born:} proc record { op rec args } { upvar type-$rec type upvar len-$rec len switch -exact $op { define { set type $args set len [ llength $args ] } new { set varname [ lindex $args 0 ] set args [ lreplace $args 0 0 ] upvar $varname instance set instance [ eval list $rec $args ] } get { upvar $rec instance set rec [ lindex $instance 0 ] upvar type-$rec type set element [ lsearch -exact $type $args ] if { $element == -1 } { bail "no such element $args in $rec" } else { incr element return [ lindex $instance $element ] } } set { upvar $rec instance set instname $rec set rec [ lindex $instance 0 ] upvar type-$rec type set field [ lindex $args 0 ] if { [ llength $args ] == 1 } { return [ uplevel record get $instname $field ] } set value [ lrange $args 1 end ] set element [ lsearch -exact $type $field ] if { $element == -1 } { bail "no such element $field in $rec" } else { incr element return [set instance [lreplace $instance $element $element $value]] } } } } if 0 { What's different here? Well, rather than dragging the field names around with each individual record we can define a prototype list. This prototype names the fields of the record, and is used to look up which field you want when you ask for it, or change it. Dicts, keyed lists, and array all incur this overhead. Records have only one definition, objects declared this way consist only of their record type and the actual data for each field. For a (trivial) example: } #source record.tcl - as needed record define person name height weight record new person larry "" "" "" record set larry name "Larry Smith" record set larry height 6'4\" puts "Larry: $larry" puts "larry.height=[record get larry height]" puts "larry.height=[record set larry height]" if 0 { the notation is not compact, but I left it this way to show how it works. Any of the normal currying methods like [Custom curry] can shorten it easily. } ---- ---- !!!!!! %| [Category Data Structure] |% !!!!!!