et4 <
tcl...@rocketship1.me> wrote:
> On 8/29/2022 1:05 PM, Rich wrote:
>
>>
>> Due to the way the TCL parser works, in this particular instance, a
>> "comment out block" using "#" characters does not work. Comment
>> characters in Tcl work differently than in Bash or other languages that
>> use # as a line comment character. They have worked this way in TCL
>> since circa 1988. They are not likely to change now, 34 or so years
>> later.
>
> True, however, the manual entry on rule 10 could be improved.
It does require understanding a fair bit more of the overall context of
the other rules to fully recognize what it is describing.
> The problem here is with the clause:
>
>
> ... then the hash character and the characters that follow it, up through
> the next newline, are treated as a comment and ignored.
Yes, in part because understanding what that clause means requires
realizing that this leading clause is of critical importance:
If a hash character ("#") appears at a point where Tcl is expecting
the first character of the first word of a command
To fully understand this clause requires recognizing that in the OP's
code structure, that troublesome # is not recognized as a command until
after the processing of rule 6 (braces) is complete. And it is the
brace processing that results in the # becoming an empty comment inside
the "then" branch of the if. Had OP not tried to comment out a valid
bit of if branch code, he might instead have hit the "missmatched brace
in comment" error that also confuses many early TCL'ers.
> At minimum, it could say, "up through the next newline or the end of
> the script, whichever comes first". However, I doubt that new tcl
> programmers would fully appreciate the distinction.
True. Better might be to add a statement to the effect of: "comment
recognition occurs after the brace processing of rule 6 has been
completed." But even something like that requires a fair amount of
contextual understanding of the other rules of TCL to recognize the
real meaning that it is attempting to convey. There may not be any
good way to write something up without becoming a very wordy tome.