[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Tcl comments and if statements
> That's what you'd expect, but try the following:
>
> -------------------
> proc parse { } {
> # if {1} {
> if {1} {
> label .b -text okay
> pack .b
> } else {
> label .b -text {not okay}
> pack .b
> }
> }
>
> parse
> ----------------
>
> The code should produce a parse error, when normally you wouldn't expect
> that it would. If you remove the open-brace in the comment, or adjust the
> code so that it's no longer a procedure, then the error message disappears.
>
> Brent Welsh's book has a warning about this tcl "feature" (page 17 in the
> 3rd edition).
>
Thank you, that clears up the confusion. Clearly, there is a difference
between the tcl language -- "If the first nonblank character of a command
is a #, the # and all characters following it up through the next
newline are treated as a comment and disgarded.", Ousterhout, 1994, p. 37
-- and the tcl implementation.
Thanks,
Greg Cook
cook@purdue.edu