Recent Changes - Search:

List

Tcl - Everything is a List

Much is heard that everything in Tcl is a string.

However, for every line of Tcl you execute, the command and arguments are first parsed into a list.

This means if you don't understand list parsing rules, Tcl can be very difficult to learn and use.

List Rules

The safest way to make a list is with the list command.

  set l [list A B C]

This isn't really necessary if you are just using simple strings as above, eg

  set l "A B C"
  set l {A B C}

However, if variables, proc calls or non-alnum chars are involved that is the only safe way, eg.

  set l [list $a $b $c]
  set l [list [Foo] B C]
Edit - History - Print - Recent Changes - Search
Page last modified on January 14, 2010, at 05:23 PM