Reputation: 292
Well I do not have much experience with tcl but while i was writing a few test cases today all of a sudden the complier kept saying Missing '}' and i had to go through like atleast 50 to 60 brace pairs to make sure all were right, and after spending about 1.5 hours on this mistake it was really annoyed to find out that i forgot to close my comment with a '}' so the following is the code in my comment
#test XmlDAOTest-1.15 {Test XmlDAO - method - 'ProcessCDATASectionNode'\
So if you see, i have commented the line and i did not close it with the '}' because comments are not supposed to be compiled and checked for syntax, only after i appended a '}' after the '\' the compiler gave me the result. I am using the following
IDE - Eclipse Indigo Version of Tcl - Tcl/Tk 8.5 with tclOO
Version: Indigo Service Release 2 Tcltest, tDom all included
Build id: 20120216-1857
I want to know if this is a Flaw on the side of the IDE or is it inherent to TCL/Tk and if it is a problem in TCl are there anymore like these that you have encountered.
Upvotes: 1
Views: 548
Reputation: 16282
The issue you are seeing is due to Tcl, not your IDE. That being said, it's not a "problem" with Tcl, just an artifact of how the code is parsed. In Tcl, the has symbol only starts a comment in places where it would be valid to start commands and, as such, comments need be parsed at the same time as the rest of the code. Since the code is not "preprocessed" to remove comments, the quotes and braces need to be balanced.
To give you an example of why the parsing is done this way:
set x #abc
In the above line, the value of x is #abc
. If comments were preprocessed, the above would convert to just set x
and the rest would disappear.
Along the same lines, and another place many people get bitten by with comments:
switch -exact -- $myvalue {
# this is not a comment
"a value" { do something }
"another value { do something }
}
In the above, #
, is
, and a
are all switch cases; you can also look at it this way (which is the same thing)
switch -exact -- $myvalue {
"#" { this }
"is" { not }
"a" { comment }
"a value" { do something }
"another value" { do something }
}
The reason for this is that the inside of a switch statement, where it's looking for case values, is not a valid place for a command. As such, the #
is just a normal character the same as any other.
Upvotes: 1
Reputation: 29266
The '\' at the end of the line is also a continuation marker, so it could be pulling the next line into the comment.
e.g.
#puts "1";\
puts "2";
puts "3";
Will output 3 because the 2nd line is treated as part of the comment.
Upvotes: 2