错误或功能? Tcl 中缺少结束引号很少被视为语法错误。

Bug or feature? Missing closing quote in Tcl is rarely seen as syntactically incorrect.

我用 Tcl 8.3 和 8.5 试过:语句

puts X"

语法正确,只输出一个 X 和一个双引号。我本以为 Tcl 会抱怨缺少收盘价。 OTOH,如果我输入语句

puts "X

puts "

在 tclsh 中,语句尚未执行,但 tcls 希望我在下一行继续字符串。

哪个句法规则阻碍了我看起来异常的事情?

不要认为这是一个错误,如文档中所述:reference here

[3] Words. Words of a command are separated by white space (except for newlines, which are command separators).

[4] Double quotes. If the first character of a word is double-quote (“"”) then the word is terminated by the next double-quote character. If semi-colons, close brackets, or white space characters (including newlines) appear between the quotes then they are treated as ordinary characters and included in the word. Command substitution, variable substitution, and backslash substitution are performed on the characters between the quotes as described below. The double-quotes are not retained as part of the word.

关键部分是如果单词的第一个字符是双引号(“"”),那么该单词将由下一个双引号字符终止。

因此,在您的情况下,如果单词以 " 开头,则预期结束双引号,如果单词不以 " 开头,那么 " 将被视为单词的一部分不像变量替换语法那样特殊。