Tcl/Tk的Switch模块中慎用注释
来源:互联网 发布:rainbow软件下载 编辑:程序博客网 时间:2024/06/01 19:16
今天改了一段Tcl代码,一段非常复杂的非常长的swith代码,总是遇到这样一个奇怪的错误:
"extra switch pattern with no body, this may be due to a comment incorrectly placed outside of a switch body - see the "switch" documentation"
于是我检查{}是否匹配,检查entry写的是否正确,检查switch的变量是否正确……反复几遍之后,错误仍然在,几近崩溃。
Google了半天,也没找到解决方法。
最终还是抱着试试看的心态打开了Tcl/Tk经典书《Practical Programming in Tcl and Tk》,打开第六章第二节,发现本节结束处赫然写着这样一段话:
A comment can occur only where the Tcl parser expects a command to begin. This restricts the location of comments in a switch command.
You must put them inside the command body associated with a pattern, as shown in Example 6-6. If you put a comment at the same level as
the patterns, the switch command will try to interpret the comment as one or more pattern-body pairs.
该示例如下:
我赶紧查看了一下我的代码,发现有好几个处“} ;#end of XXX”这样的注释。把它们去掉之后,就可以正常work了。
下面就是带有错误注释的不能工作的代码段。
由此得知,虽然“;#”这样的注释在Tcl中一般是很常见的,但是在switch中语句中是不能用的,只能在单独一行里写注释。
以此文为记。
- Tcl/Tk的Switch模块中慎用注释
- tcl/tk的安装
- tcl/tk的安装
- tcl/tk 的安装
- tcl/tk实例详解——switch
- Tcl/Tk入门(中)
- tcl/tk脚本中使用大量重复代码的解决方法
- tcl/tk中大括号与双引号分组的不同
- Tcl的历史--Tcl/Tk简介
- Tcl/Tk的一些笔记
- Tcl/Tk的一些笔记
- Tcl/TK -- upvar 的用法
- tcl/tk参考——控制结构switch
- tcl/tk
- TCL/TK 与 C 程序的集成
- 菜鸟文档::Tcl/Tk的使用环境
- TCL/TK 与 C 程序的集成
- 关于Tcl/Tk 的几个解释环境
- git 简单命令使用
- git 简单命令使用
- SHFileOperation操作
- c语言写了一个简单的正弦波函数
- git 下载 android 源码
- Tcl/Tk的Switch模块中慎用注释
- 蜗居客,就是一个传说(1)
- php抓取网页代码四种方法
- 2010年计算机专业基础综合大纲解析
- 毕业前的准备
- JSF和Spring的集成
- oracle的jdbc连接方式:oci和thin
- 在Linux下访问Windows
- SHGetFileInfo 在WINCE下获得系统图标列表