How to put block comments in Tcl?

Apart from the if {0} .. which is idiomatic (and one that most tcl programmers recognize) you can also use any other construct and stuff the things you want commented out in brace quotes. The real mechanism preventing execution here is that things inside brace quotes don't get substituted.

Here are some of my favourites. I like them because they are self-documenting:

set COMMENTED_OUT {

    commented out stuff

}

and

proc COMMENTED_OUT {} {

    commented out stuff...

}

I tend to prefer the proc because the block of commented out text is really a block of code.

Note that tcl does not compile proc bodies until first execution so commenting out using a proc is as cheap as set and if {0} ...


Use something along these lines:

if { 0 } {
    a section
    of
    "commented" code
}

Tags:

Tcl