claird@lairds.us (Cameron Laird) writes:
> be prevented. In any case, thanks to Donal and Donald for
> their write-ups; to my eye, they're right on target.
Parts of mine are badly worded, and I like Donal's wording much
better, plus some of the suggestions for explicit mention of non-substitution.
However, I would my the mention of backslash-protection to be made
(but worded better); I thought it is significantly lacking from the
current version -- both in the variable-substitution rule *and* in the
backslash-substitution rule.
Also, I liked having the more explicit mention of what determines
the end of $name, but it is not critical. Make sure *not* to say
"until the next dollar-sign"!
Here is another possibility...
If a word contains a dollar-sign (``$'') followed by one of the forms
described below, then Tcl performs variable substitution: the
dollar-sign and the following characters are replaced in the word by
the value of a variable. The forms are:
$name
Name is the name of a scalar variable; the name is a sequence of one or more
characters that are a letter, digit, underscore, or namespace separators
(two or more colons), which are followed by a character that is not among these
or by the end of the word.
$name(index)
Name gives the name of an array variable and index gives the name of an
element within that array. Name must contain only letters, digits, underscores,
and namespace separators, and may be an empty string. Command substitutions,
variable substitutions, and backslash substitutions are performed on the
characters of index.
${name}
Name is the name of a scalar variable. It may contain any characters whatsoever
except for close braces, or it may be an empty string.
There may be any number of variable substitutions in a single word.
Variable substitution is not performed when the material does match one of
the three forms, nor is it performed when a dollar-sign is preceded by a
backslash and undergoes backslash substitution, nor is it performed on words
enclosed in braces. In such cases the dollar-sign remains in the text.
--
Donald Arseneau asnd@triumf.ca
Received on Fri Dec 23 19:02:40 2005