Re: why is this happening ?



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
.



Relevant Pages

  • Re: Results of the memswap() smackdown from the thread "Sorting" assignment
    ... (but not as good as Ben's optimization) ... any "GO TO" feature of a language isn't a threat. ... stop being upset at the notion of calling memcpy() from the lib. ... printf("%d\n", FOO); ...
    (comp.programming)
  • Re: Case sensitivity in programming languages.
    ... is a variable called $foo I expect $Foo and $FOO to mean the same thing, ... Programmers who deliberately create different variables with the same name but different case are bad programmers, but a *proper* language removes the possibility for such bad programming by ignoring case and treating all the variables as a single variable. ... Having $foo, $Foo and $FOO mean different things causes more problems than it solves, as does haing different functions called readfile(), readFileand ReadFile. ...
    (comp.lang.php)
  • Re: Relative merits of Lisp-1 vs. Lisp-2?
    ... confusing things like (foo foo) ... Somewhat simplified language description, somewhat simplified ... For Lisp-2: ... have only Scheme but in the other world you admit that both Scheme and ...
    (comp.lang.lisp)
  • Re: What is the reason for this syntax?
    ... // adding 1 to foo ... language will understand a case statement. ... rigidity however unlike programming languages spoken and written ... adversly affect the readability of the language itself be addressed ...
    (comp.lang.ruby)
  • Re: new here, my lang project...
    ... >> function foo() ... &foo is not using a string, ... > Originally we used a custom language for the program because we thought it ... understand" and similar is a useful feature, however, the format needs at ...
    (comp.object)