Everything is a string - even a list
Archive - Originally posted on "The Horse's Mouth" - 2015-03-11 05:44:43 - Graham EllisAlmost all variables in Tcl are held as strings ... if you use integers and stirings in calculations such as expr and incr. the strings are converted back and forth intergally. Lists, too, are held as strings of characters in which chunks of string are counted / taken out as being elements in the list. Here's an example setting up a list ... and then reporting the length as a list (where it contains two values), and as a string (where it contains 15 letters).
% set daze "Monday Chewsday"
Monday Chewsday
% puts daze
daze
% puts $daze
Monday Chewsday
% put [string length $daze]
15
% put [llength $daze]
2
%
Note my use of almost - Tcl's arrays are NOT held as simple strings - and that does make a difference (later in Tcl course we'll take a look at this)