> So, I've been writing Tcl for AOLserver since it only ran Tcl 7.4, and you
> only had 3 choices for storing data in Tcl -- scalars, lists and arrays.
> Things like a list of arrays weren't possible; if you wanted to have such
> a thing, you had to fake it.  I admit, I've gotten used to being able to
> do such things in Perl, where an array of hashes is an ordinary thing (or
> at least an array of hash references), and I have to say that I find it
> convenient.  How do Tcl programmers normally do such things?  Do they

As you found at:
        http://wiki.tcl.tk/1481

using lists and lists of lists is very efficient with 8.4.  All the
info is passed around by reference at the C level.  For something like:

        set a [list \
                        [list a b c] \
                        [list d e f] \
                ]
        set b [lindex $a 1]

$b just points to the same [list d e f] object that is part of $a.  All
this manipulation is very fast.

Some prefer to abstract the use of lindex and lset by extra procs that
are more "meaningful" (like 'access $key'), but that's adds very little
overhead.

You can go beyond the core to use extensions like XOTcl to create
whatever you want in terms of classes and OO objects.

  Jeff Hobbs                     The Tcl Guy
  Senior Developer               http://www.ActiveState.com/
      Tcl Support and Productivity Solutions

Reply via email to