Version 13 of element

Updated 2004-08-15 08:00:08 by lwv

Purpose: describe what Tcl considers a list element - i.e. the basic component of a list.


Given that Tcl considers everything is a string, then a list element is, at its core, just a string. This string can either be 0 length, 1 or more characters, and can be formatted in such a way that the element is also another list.

However, just because every element is a string does NOT mean that every string is a list element.

In Tcl, one programatically ensures a string is a list element most safely by usign either the list or the split command to listify the string.

However, many times developers, when coding a literal string, quote with the \\ the { characters to simulate the listifying process. I have also seen developers use regular expressions to try to simulate this process. It seems like just using list or split would be clearer.


See also list, lappend, lindex, linsert, llength, lrange, lreplace, lsearch, lsort, concat, split, foreach, array .

caspian recommends that you also see: join and lset


Tcl syntax help

Category Glossary