In Tclers wiki page, at 'Dodeklogue' it is mentioned about comments:
Comments: If # appears where a command is expected, the rest of the line is a comment. No command execution is attempted, and no characters in the line are interpreted, except that the terminating newline may be escaped with \, signifying that the comment continues on the subsequent line.
However, it seems that comments are interpreted byond the terminal \: for example, let the content of file test.tcl be as below:
proc test {} {
# Open brace {
puts "I am fine"
}
test
t
Then
tclsh test.tcl gives the following error message:
missing close-brace: possible unbalanced brace in comment
while executing
"proc test {} {"
(file "hello.tcl" line 1)
Even more interesting
Even more interesting, when the open brace { is replaced with close brace }, the error message is completely different.
Why does Tcl interpreter try to make sense of what is there in a comment, what would we lose if the Tcl interpretor (or any interpretor in general) was designed to take comments as real comments: once you see # completely ignore until the new line (except, check last character of comment if it is \) ?
proc foo {} { # do nothing }? Do you think the closing brace should be part of the comment (thus requiring a closing brace on the next line), or do you think it should end the proc definition? - Bryan Oakley