Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Funny comments

Closed / Invalid1834653fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-11-19 17:10:56
Try the following:

if { 0 } {
  puts "00"
#} elseif { 1 } {
# puts "11"
  puts "22"
}

It prints '22' !

I did not try the newest 8.4, but I guess it would be the same.

Regards
msoferplain2007-11-20 00:34:55
Logged In: YES 
user_id=148712
Originator: NO

That is correct behaviour: braces are parsed before comments in Tcl. This is contrast to C, where comments are removed by the preprocessor before any parsing occurs.

Your code is understood exactly as if it were written
  if { 0 } {
    puts "00"
    #
  } elseif { 1 } {
    # puts "11"
    puts "22"
  }
}

Please refer to the Tcl.n man page (http://www.tcl.tk/man/tcl8.4/TclCmd/Tcl.htm) and/or the wiki (http://wiki.tcl.tk/462).
Log in (anonymous is fine) to add a comment.