1Tcl(n)                       Tcl Built-In Commands                      Tcl(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       Tcl - Tool Command Language
9

SYNOPSIS

11       Summary of Tcl language syntax.
12______________________________________________________________________________
13

DESCRIPTION

15       The  following  rules  define  the syntax and semantics of the Tcl lan‐
16       guage:
17
18       [1] Commands.
19              A Tcl script is a string containing one or more commands.  Semi-
20              colons  and  newlines  are  command  separators unless quoted as
21              described below.  Close brackets are command terminators  during
22              command substitution (see below) unless quoted.
23
24       [2] Evaluation.
25              A command is evaluated in two steps.  First, the Tcl interpreter
26              breaks the command into  words  and  performs  substitutions  as
27              described  below.  These substitutions are performed in the same
28              way for all commands.  Secondly,  the  first  word  is  used  to
29              locate a command procedure to carry out the command, then all of
30              the words of the command are passed to  the  command  procedure.
31              The  command procedure is free to interpret each of its words in
32              any way it likes, such as an integer, variable  name,  list,  or
33              Tcl  script.   Different  commands interpret their words differ‐
34              ently.
35
36       [3] Words.
37              Words of a command are separated by white space (except for new‐
38              lines, which are command separators).
39
40       [4] Double quotes.
41              If  the first character of a word is double-quote (“"”) then the
42              word is terminated by the next double-quote character.  If semi-
43              colons,  close  brackets,  or  white space characters (including
44              newlines) appear between the quotes then  they  are  treated  as
45              ordinary characters and included in the word.  Command substitu‐
46              tion, variable substitution, and backslash substitution are per‐
47              formed  on the characters between the quotes as described below.
48              The double-quotes are not retained as part of the word.
49
50       [5] Argument expansion.
51              If a word starts with the string “{*}” followed by a  non-white‐
52              space  character, then the leading “{*}” is removed and the rest
53              of the word is parsed and substituted as any other  word.  After
54              substitution,  the  word is parsed as a list (without command or
55              variable substitutions; backslash substitutions are performed as
56              is  normal  for a list and individual internal words may be sur‐
57              rounded by either braces or double-quote  characters),  and  its
58              words  are added to the command being substituted. For instance,
59              “cmd a {*}{b [c]} d {*}{$e f {g h}}” is equivalent to “cmd  a  b
60              {[c]} d {$e} f {g h}”.
61
62       [6] Braces.
63              If the first character of a word is an open brace (“{”) and rule
64              [5] does not apply, then the word is terminated by the  matching
65              close  brace (“}”).  Braces nest within the word: for each addi‐
66              tional open brace there must be an additional close brace  (how‐
67              ever,  if an open brace or close brace within the word is quoted
68              with a backslash then it is not counted in locating the matching
69              close  brace).  No substitutions are performed on the characters
70              between the braces except  for  backslash-newline  substitutions
71              described  below,  nor do semi-colons, newlines,