Re: why is this happening ?
- From: Bryan Oakley <oakley@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 02 Jun 2006 16:27:04 GMT
maura.monville@xxxxxxxxx wrote:
This is the most astonishing thing I've ever heard about a programming
language !
I've always thought of comments as an easy way to narrow down an error
in a long chunk of code, if a debugger is not available, by
incrementaly removing code lines from the execution flow.
But with Tcl this old trick is out of the question ....
Yes, it is astonishing. Some consider it a wart on Tcl since you have to think long and hard to understand it's advantages. The whole trick to learning Tcl is to forget all the assumptions you have about programming languages.
Stick to the rule "don't have quoting characters in comments" and the problem mostly vanishes.
I quickly browsed through the web pages you suggested.
It looks like "#" is a strt comment marker only if it is basically he
first character in a new line ..... hopefully the interpreter is not
sensetive to this character position (column) in the line..
More accurately, "at a point where Tcl is expecting the first character of the first word of a command", from the Tcl(n) man page
http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm#M28
So I cannot append a comment on the same line where there is a command.
Incorrect. As long as tcl expects a command, you can place a comment:
set foo "bar" ;# this is a valid comment
This is an important rule to remember. For example, you can /not/ do this:
switch $foo {
# the normal case
0 {<handle the case where foo is zero}
# warning
1 {<handle the case where foo is 1>}
# error
default {<handle the case where foo is anything else>}
}
Why? Because inside the switch, Tcl isn't expecting a command. The switch statement is expecting groups of patterns and bodies, not commands.
In C/C++ I use to write a short comment on the left side of long nested
loops to remember what it does. But here it's forbidden. Am I right ?
On the left side? Yes, you are correct. You can, however, put them on the right. I do it all the time at the end of long blocks of code:
namespace eval whatever {
...
} ;# namespace eval whatever
--
Bryan Oakley
http://www.tclscripting.com
.
- References:
- why is this happening ?
- From: maura.monville@xxxxxxxxx
- Re: why is this happening ?
- From: Ralf Fassel
- Re: why is this happening ?
- From: Cameron Laird
- Re: why is this happening ?
- From: maura.monville@xxxxxxxxx
- why is this happening ?
- Prev by Date: Re: why is this happening ?
- Next by Date: mysqltcl fails to install
- Previous by thread: Re: why is this happening ?
- Next by thread: Re: why is this happening ?
- Index(es):
Relevant Pages
|