Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2022-08-29
12:39 • Closed ticket [32dd97149b]: tcl comment syntax BUG plus 7 other changes artifact: 332cdb59b5 user: jan.nijtmans
07:02 • New ticket [32dd97149b]. artifact: b69dcdad95 user: anonymous

tcl comment syntax BUG

Closed / Invalid32dd97149b4aa2f943f9a8d04bf0ecda8b348084Created 4 years agoUpdated 4 years ago
Descriptionplain2022-08-29 07:02:13
Hi, put code down in a "extra2.test" file and call it with :

tclsh extra2.test 1 or 2 or 3

===============================
lassign $argv num

if { $num == 1 } {

  puts 1

# } elseif { $num == 2 } {
#
#   puts 2

} else {

  puts 99

}
=================================

> tclsh extra2.test 1
1

> tclsh extra2.test 2
!! nothing !!

> tclsh extra2.test 3
99
jan.nijtmanswiki2022-08-29 12:39:46

This is not a bug, but it's how the Tcl parser works.

Everything between '{' and '}' is always taken literally and fed to the command, the command is fully responsible for interpreting this string. In case of 'if', the command interprets the 3th argument as code, which contains a last line starting with '#' and ends just before '}'. So the effect of the first '#' ends with the following '}', not at the end of the line.

Hope this helps, Jan Nijtmans

Log in (anonymous is fine) to add a comment.