| Ticket UUID: | 3a24cc9df1619a130120e8cef8560aef0561c1f0 | |||
| Title: | Switch statement case fails when using a open parenthesis in a comment | |||
| Type: | Bug | Version: | 9.x | |
| Submitter: | mookie | Created on: | 2025-04-12 22:42:59 | |
| Subsystem: | 69. Other | Assigned To: | nobody | |
| Priority: | 2 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2025-05-02 07:48:56 | |
| Resolution: | Invalid | Closed By: | pooryorick | |
| Closed on: | 2025-05-02 07:48:56 | |||
| Description: |
Example code:
proc yay {lang} {
switch $lang {
tcl {
puts "Yay! TCL"
# having this { will break this case now
}
}
} ;# end proc
I then have to apply an additional { to the get the syntax to execute but results with invalid command name "}"
% yay "tcl"
Yay! TCL
invalid command name "}"
Not sure feature, or bug; so feel free to close.
Surely a comment is a comment and shouldn't be executed? If recall correctly it's down to that switch cases are executed as lists. FWIW.
| |||
| User Comments: |
mookie added on 2025-04-28 14:19:16:
Many Thanks. griffin added on 2025-04-12 23:57:56: This behavior is expected. Tcl is not parsed like other programming languages. It is an organized collection of strings that can be evaluated to do things. Read this man page carefully. https://www.tcl-lang.org/man/tcl8.6/TclCmd/Tcl.htm It defines everything you need to know about Tcl. This is an over simplification: There is no “comment” in Tcl. Instead, commands that start with a # are ignored. I hope this helps. | |||