Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2025-05-02
07:48 • Ticket [3a24cc9df1] Switch statement case fails when using a open parenthesis in... artifact: 6e7284f52c user: pooryorick
2025-04-28
14:19 • Closed ticket [3a24cc9df1]. artifact: 3b8cbf15dc user: mookie
2025-04-12
23:57 • Ticket [3a24cc9df1]: 3 changes artifact: ff6dcaf77d user: griffin
22:48 • Ticket [3a24cc9df1]: 4 changes artifact: 3403614bce user: mookie
22:45 • Ticket [3a24cc9df1]: 4 changes artifact: 127b1ab3c2 user: mookie
22:45 • Ticket [3a24cc9df1]: 3 changes artifact: ca870d1eb8 user: mookie
22:44 • Ticket [3a24cc9df1]: 3 changes artifact: c17a0cfb61 user: mookie
22:43 • Ticket [3a24cc9df1]: 3 changes artifact: 2be0e11855 user: mookie
22:42 • New ticket [3a24cc9df1]. artifact: abeebf93f1 user: mookie

Switch statement case fails when using a open parenthesis in a comment

Closed / Invalid3a24cc9df1619a130120e8cef8560aef0561c1f0Created 2 years agoUpdated 2 years ago
Descriptionplain2025-04-12 22:42:59
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.
mookie Ticket [3a24cc9df1]: 3 changes [History diff]2025-04-12 22:43:40
mookie Ticket [3a24cc9df1]: 3 changes [History diff]2025-04-12 22:44:41
mookie Ticket [3a24cc9df1]: 3 changes [History diff]2025-04-12 22:45:11
mookie Ticket [3a24cc9df1]: 4 changes [History diff]2025-04-12 22:45:50
mookie Ticket [3a24cc9df1]: 4 changes [History diff]2025-04-12 22:48:16
griffinplain2025-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.
mookieplain2025-04-28 14:19:16
Many Thanks.
pooryorick Ticket [3a24cc9df1]: 5 changes [History diff]2025-05-02 07:48:56
Log in (anonymous is fine) to add a comment.