Question:code
error: missing close-brace: possible unbalancd brace in commentio
直译是缺乏括号,通常来讲检查一下括号是否匹配就能够。但Tcl中,被注释的括号有时也会被算入。以下:class
set namelist1 [list a b c d e] set namelist2 [list 1 2 3 4 5] foreach name $namelist1 { #foreach name $namelist2 { puts -nonewline $name }
在这段程序中,我更换了须要遍历的列表,因此将以前的foreach
语句注释掉。这种状况下就会报错。但神奇的是,若是被注释的括号不在其余括号内部就不会报错:foreach
set namelist1 [list a b c d e] set namelist2 [list 1 2 3 4 5] #foreach name $namelist2 { foreach name $namelist1 { puts -nonewline $name }
Solution:遍历
建议直接将注释删掉,再或者在注释中也保持括号匹配。以下,注释末尾增长一个}
就不会报错。程序
set namelist1 [list a b c d e] set namelist2 [list 1 2 3 4 5] foreach name $namelist1 { #foreach name $namelist2 {} puts -nonewline $name }