( ESNUG 424 Item 7 ) -------------------------------------------- [03/09/04]
From: Gzim Derti <derti=user domain=agere spot calm>
Subject: Gzim Discovers & Then Rediscovers A Nasty Tcl "{" Commenting Bug
Hi John,
I guess, according to Synopsys R&D, that the following isn't a problem as
"it's the way TCL works". And according to some feedback I got from Bob
Wiegand, links below, they seem to be correct.
http://bmrc.berkeley.edu/mhonarc/openmash-users/msg00062.html
http://bmrc.berkeley.edu/mhonarc/openmash-users/msg00070.html
But I just wanted to note this to prevent someone else from experiencing
the joy of trying to debug this type of issue with their TCL scripts...
It seems that within a procedure (and I believe only a procedure) if you
comment out a line that ends in a "{" (that's a left curly-brace in case
it's not easily legible in your font of choice) such as an
if, foreach, foreach_in_collection, etc.
You'll get a parse error upon read-in of the procedure... and if you've
made more than one change to test things out, the LAST thing you're going
to look at is the line you just commented OUT of your code... which is why
this will drive you nuts if you run into it...
Example of a bad code snippet:
proc coll_names {$inpt_coll} {
#foreach_in_collection inpt $inpt_coll {
foreach_in_collection inpt $inpt_coll {
echo [get_object_name $inpt]
}
}
If the above code lives in the file coll_names.tcl, and you source it:
source coll_names.tcl
You'll get the following oh-so-descriptive error:
Error: EOF found before command was complete
Use error_info for more info. (CMD-013)
Which DOES make sense, after you realize that the parser is expecting to
see a missing right-curly in the file:
proc coll_names {$inpt_coll} {
#foreach_in_collection inpt $inpt_coll {
foreach_in_collection inpt $inpt_coll {
echo [get_object_name $inpt]
}
#} <- Note the commented out right-curly
}
Or if you remove the commented out first line all together, rather than
commenting it out temporarily.
I found this issue back when DC-TCL first came out, figured it out then,
but never looked into it beyond a "don't do that" stage, and forgot about
it until recently again... And got grayer due to it... Possibly balder
too, but we won't get into that...
- Gzim Derti
Agere Systems
|
|