:TITLE: Evaluation & Substitutions 2: Grouping arguments with {}
;#
;# RCSID: $Header: /home/cvs/TclTutor3/lesson/Tcl_English/Tcl_English4.lsn,v 1.1 2008/08/02 12:37:17 clif Exp $
;# Copyright (c) 1995 Clif Flynt
;# 9300 Fleming Rd.
;# Dexter, MI  48130
;# clif@cflynt.com
;# See file "NOTICE" for licensing terms.
;#
:LESSON_TEXT_START_LEVEL 0:
During the substitution phase of command evaluation, the two grouping
operators, the brace ({) and the double quote ("), are treated
differently by the Tcl interpreter.
<P>
Grouping a set of words within braces disables all of the substitutions
that can occur within a set of words grouped by quotes.  The characters
within braces are passed to a command exactly as they are written. 
<P>
The only "Backslash Sequence" that is processed within braces is
the backslash at the end of a line.  This is still a line continuation
character. 
<P>
If you haven't hit the <B>Run Example</B> button yet, do so now, and examine
the results of the example.  Play around a bit with the example code, and
then go on to the next lesson.
:TEXT_END:
:LESSON_TEXT_START_LEVEL 1:
During the substitution phase of command evaluation, the two grouping
operators, the brace ({) and the double quote ("), are treated
differently by the Tcl interpreter.
<P>
In the last lesson you saw that grouping words with
double quotes allows substitutions to occur within the
double quotes.  By contrast, grouping words within
double braces *disables* substitution within the
braces.  Characters within braces are passed to a
command exactly as written.  The only "Backslash
Sequence" that is processed within braces is the
backslash at the end of a line.  This is still a line
continuation character.
<P>
Note that braces have this effect only when they are used as a grouping
operator.  If a string is already grouped, either with quotes or braces,
and braces occur within the grouped string, then the braces are treated
as ASCII characters.  If the string is grouped with quotes,
substitutions will occur within the quoted string, even between the
braces. 
<P>
If you haven't hit the <B>Run Example</B> button yet, do so now, and examine
the results of the example.  Play around a bit with the example code, and
then go on to the next lesson.
<P>
:TEXT_END:
<P>
:LESSON_TEXT_START_LEVEL 2:
 In the last lesson, you learned that both double quotes
("") and braces ({}) can be used to group a set of
words into a single unit.  However, these two grouping
operators do not behave the same during the
substitution phase of command evaluation.
<P>
Where double quotes allow substitutions to occur within
the quoted string, braces *disable* substitution.  The
set of words grouped by the braces is evaluated exactly
as written.  For example, the string
<PRE><CODE>
     {$variableName}
</CODE></PRE>
will be passed to a command as
<PRE><CODE>
      $variableName
</CODE></PRE>
and no substitution will occur.  The only "Backslash
Sequence" that is processed within braces is the
backslash at the end of a line.  This will still cause
two lines to be evaluated as though there were no
newline after the backslash.
<P>
Note that braces have this effect only when they are used as a grouping
operator.  If a string is already grouped, either with quotes or braces,
and braces occur within the grouped string, then the braces are treated
as ASCII characters.  If the string is grouped with quotes,
substitutions will occur within the quoted string, even between the
braces. 
<P>
If you haven't hit the <B>Run Example</B> button yet, do so now, and examine
the results of the example.  Play around a bit with the example code, and
then go on to the next lesson.
:TEXT_END:
:CODE_START:
set Z "Albany"
set Z_LABEL "The Capitol of New York is: "

puts "\n................. examples of differences between  \" and \{"
puts "$Z_LABEL $Z"
puts {$Z_LABEL $Z}

puts "\n....... examples of differences in nesting \{ and \" "
puts "$Z_LABEL {$Z}"
puts {Who said, "What this country needs is a good $0.05 cigar!"?}

puts "\n................. examples of escape strings"
puts {There are no substitutions done within braces \n \r \x0a \f \v}
puts {But, the escaped newline at the end of a\
string is still evaluated as a space}
:TEXT_END:

