Version 1 of pure list

Updated 2002-03-04 23:51:39

A pure list in Tcl is a value that has a list internal representation but no string representation.

Pure lists are significant primarily because the evaluator and bytecode compiler treat them specially. If confronted with a pure list, these components can recognize immediately that

  • the object in question is a single Tcl command; the words making up the command are precisely the elements of the list.
  • the object requires no substitution.

They can therefore avoid using a parser on the object. They simply look up the command (element 0 of the list), and construct a parameter vector consisting of the list elements.

Pure lists are preferred for callbacks such as traces, [eval] and [uplevel], [after] calls, Tk commands and bindings, and similar applications.

The [list] command always returns a pure list.

Is it essential that there be no string rep - isn't a list rep sufficient for this either way? -jcw