Grouping Elements with Braces
Braces group separate elements together creating a new element that consists of everything between a left brace and its corresponding right brace. You can also nest braced elements.
Each of the following example lists contain three elements:
larry moe curly 1 {3 5 7 11 13} {17 19} red {orange yellow {green blue} indigo} violet
Braces disable command [ ], variable $, and backslash (\) substitution. While the most important use of braces is to ensure a dcecp command has the correct number of
arguments, this also provides a convenient way to include special characters in a list. To see how this works, consider the following example.
dcecp> set a solution solution dcecp> puts $a solution dcecp> puts {This is a convenient $a} This is a
convenient $a
While the puts command is often used for writing to files, when called with only one argument it writes the argument to stdout. In our example, the first use of puts
allows normal interpretation of the variable a. The second use of puts groups the separate elements into one argument by disabling special interpretation of space characters and
the dollar sign.
|