anyone know how to do block comments in tcl? is it even possible?
the only comments talked about in the tcl/tk book is the hash (#) mark
so individual lines. i sure hope so. how can a modern language not
have such a thing? thanks.
/r/
--
+----------------------------------------------------------------------------+
Ronald S. Chong / rch...@umich.edu / http://krusty/people/rchong/rchong.html
Advanced Technology Laboratory / 1101 Beal Avenue, Room 147 /
University of Michigan, North Campus / Ann Arbor, MI 48109-2110 /
313.763.8530 (of) / 313.763.1260 (fx) / 313.763.8530 (hm)
+----------------------------------------------------------------------------+
RSC> hi all:
RSC> anyone know how to do block comments in tcl? is it even possible?
i don't think so; unless there's been a change in syntax in the last
eight months.
RSC> the only comments talked about in the tcl/tk book is the hash (#) mark
RSC> so individual lines. i sure hope so. how can a modern language not
RSC> have such a thing? thanks.
c++ decided to ADD such comments over c's block comments. the only
reasons i can think of:
- c's comments don't nest by default in most implementations (proper
block commenting isn't as trivial as it looks - particularly if
it's going to be allowed to "erase" huge chunks of code, in which
case one should be careful to ignore comment delimiters in string
constants, for instance. in lex/yacc models, comments would either
mess up the grammar bigtime or have a really HIDEOUS regular expression.
But i digress :-)
- a bunch of // down the side is more visible than a #if 0/#endif pair
(no comment on C programmers that use comments when they should use
#if).
now i, personally, don't consider c++ to be *modern*, despite being
new. not wanting to say any MORE lest i start YA language war, i'll
stop now. :-)
--
Hume Smith (613)SOFINER 9-5 EST hcls...@ra.isisnet.com
BNR made me sign over my opinions, and they're not keen to share.
"Unfortunately, since TCP and IP were not designed by a committee, all the
header fields serve some useful purpose..." Van Jacobsen, RFC-1144
HS> (proper
HS> block commenting isn't as trivial as it looks - particularly if
HS> it's going to be allowed to "erase" huge chunks of code, in which
HS> case one should be careful to ignore comment delimiters in string
HS> constants, for instance. in lex/yacc models, comments would either
HS> mess up the grammar bigtime or have a really HIDEOUS regular expression.
HS> But i digress :-)
whoops - REs can't do nesting.
it would be most cleanly handled *between* an RE-based lexical
analyser and a CFG-based syntax analyser. (now that i've thought a
few minutes *more*, i see block comments aren't quite as hard as i
thought, as least for the "algebraic" sorts of languages.)
sorry for this way-off-tcl stuff...
Well, its not in the language, but I find it easy enough to do in Emacs.
When in Tcl mode, you can use M-x comment-region and C-u M-x
comment-region to comment and uncomment sections, respectively.
-Karl
Karl B. Schwamb WWW: http://www.isi.edu/soar/schwamb
University of Southern California Office: (310) 822-1511
Information Sciences Institute FAX: (310) 823-6714
4676 Admiralty Way, Suite 1001 (MIME/PGP capable) sch...@isi.edu
Marina del Rey, CA 90292-6695 finger for PGP Public Key
You could try using the curly braces and a dummy proc like:
proc C# c {}
The down side is that your text in the comments must have matching
curly braces, and it is parsed into a variable. The up side
is that most 'good' (already working) code has matching braces (for
those time when you just have to block comment out parts of your
code). Also, for just text type comments, even in 'C' you had to
be careful not to put */ in the body somewhere. And this TCL
method can be nested, you can comment out your block comments.
example one:
C# {
This is a block comment. Add your own prefix symbols
to make the whole
thing look {$sweet}. Even lines with \
at the end will work just fine.
C# }
set x \$
set y \\
set z {This space for rent}
example two (block comment all of example one}:
C# { START CODE COMMENTED OUT
C# {
This is a block comment. Add your own prefix symbols
to make the whole
thing look {$sweet}. Even lines with \
at the end will work just fine.
C# }
set x \$
set y \\
set z {This space for rent}
C# END CODE COMMENTED OUT }
At least the answer wasn't a NO, no?
So this is not visually significantly different from the equivalent
Tcl style:
# This is a long comment
# etc.
# and more etc.
--
=Spencer W. Thomas | Med Ctr Info Tech, B1911 CFOB, 0704
"Genome Informatician" | Univ of Michigan, Ann Arbor, MI 48109
Spencer....@med.umich.edu | 313-764-8065, FAX 313-764-4133
True, but to quickly comment out 200 lines of code its nicer to
be able to say:
set dummy {
<lots of lines of code>...
}
no?
if 0 {
...
}
in there.
For block comments I've been writing stuff like this:
document_proc lassign {
assigns the n'th variable in the list `vars' to the n'th element
of `list'. Returns the length of `list'.
}
proc lassign {vars list} {
set i 0
foreach elt $list {
upvar [lindex $vars $i] var
set var $elt
incr i
}
return $i
}
When the program normally runs, document_proc is a stub proc:
proc document_proc {proc text} {
}
However, I have another version of document_proc that will accumulate
the document_proc constructs in a file and generate a man page.
Instant nearly painless documentation :).
--
--
Sam Shen, Lawrence Berkeley Lab, sls...@lbl.gov, http://www.lbl.gov/~sls/