TCL书中的这个例子有什么问题
What is wrong with this example in TCL book
我正在阅读"Tcl/Tk: A developer's guide",在第3.1章中,它有这样的坏例子:
if {$x > 2} {
set greater true
}
书上说这段代码是错误的语法,因为“No space between test and body left brace
”并且会得到错误信息:
Error Message: invalid command name "}"
我在 tclsh 中试过了,它工作正常。另外我不认为“{$x
”是错误的,“{”是在一个单词的开始位置,所以匹配“}”之前的任何内容都包含在内。
你看有什么不对吗?
书中只给出了不带空格的。
运行 这我们将得到以下错误。
% if {$x > 2}{
extra characters after close-brace
% set greater true
true
% }
invalid command name "}"
%
我正在阅读"Tcl/Tk: A developer's guide",在第3.1章中,它有这样的坏例子:
if {$x > 2} {
set greater true
}
书上说这段代码是错误的语法,因为“No space between test and body left brace
”并且会得到错误信息:
Error Message: invalid command name "}"
我在 tclsh 中试过了,它工作正常。另外我不认为“{$x
”是错误的,“{”是在一个单词的开始位置,所以匹配“}”之前的任何内容都包含在内。
你看有什么不对吗?
书中只给出了不带空格的。
运行 这我们将得到以下错误。
% if {$x > 2}{
extra characters after close-brace
% set greater true
true
% }
invalid command name "}"
%