On 2021-01-25, Hongyi Zhao <
hongy...@gmail.com> wrote:
> On Sunday, January 24, 2021 at 11:22:05 PM UTC+8, Eric wrote:
8>< --------
>> Unmatched braces in comments do cause problems, so completely replacing
>> the line rather than commenting it is *necessary*.
>
> Why tcl language has such strict restrictions on commented code?
The actual rule for comments is:
If a hash character (“#”) appears at a point where Tcl is expecting
the first character of the first word of a command, then the hash
character and the characters that follow it, up through the next
newline, are treated as a comment and ignored. The comment character
only has significance when it appears at the beginning of a command.
(from
http://www.tcl.tk/man/tcl/TclCmd/Tcl.htm#M30)
However, the "mismatched brace" is in a procedure definition. "proc" is
a built-in command which takes three arguments
the name of the procedure being defined
a list of the names of the arguments (possibly also defaults ...)
the body of the procedure.
The body is composed of a number of Tcl commands, so they must be grouped
to make a single argument (a "word") to "proc". Normally this is done
with braces, which are covered in another Tcl rule:
If the first character of a word is an open brace (“{”) and rule
[5] does not apply, then the word is terminated by the matching close
brace (“}”). Braces nest within the word: for each additional
open brace there must be an additional close brace (however, if an
open brace or close brace within the word is quoted with a backslash
then it is not counted in locating the matching close brace). No
substitutions are performed on the characters between the braces
except for backslash-newline substitutions described below, nor do
semi-colons, newlines, close brackets, or white space receive any
special interpretation. The word will consist of exactly the characters
between the outer braces, not including the braces themselves.
In other words, it won't notice the "#" but will notice the extra
opening brace.
And Tcl *is* its rules, there are only 12 of them. Any changes at the
rule level are likely to be both complex and controversial.