Tcl knows only one data type, namely strings. However, numeric strings are interpreted as numbers wherever appropriate.
Lists are similar to lists in Prolog, except that they are represented as strings and whitespace separators are significant for them. It does not matter if lists are grouped together with double quotes or braces (except for substitutions):
however there are subtle differences:% if {{a b c} == "a b c"} {puts yes} {puts no} yes
The main difference between lists and strings is that lists can be nested whereas strings are flat. A string is interpreted as a flat list whenever appropriate, list elements are separated by whitespace characters. The list separators are kept verbatim in the list:% puts {} % puts "" % puts {{}} {} % puts {""} "" % puts "{}" {}
% set a {a { b c } d} a { b c } d % string compare {a } { a} 1
Lists with one element are identical to atoms, so e.g.
a
and {a}
are identical:
Such lists can be explicitly created by double braces:% string compare a {a} 0
Even around braces, spaces are significant:% puts {{a}} {a}
% llength {{a b}{c d}} list element in braces followed by "{c" instead of space % llength {{a b} {c d}} 2