error-handling - 使用 Tcl info procs 返回值
问题描述
鉴于 not_there 没有我期望的过程
[info procs not_there] eq ""
返回 0,但我看到
empty command name ""
有人可以解释我的概念错误吗?
解决方案
您的这份声明:
[info procs not_there] eq ""
将首先info procs not_there
由 Tcl 解释器评估。接下来,解释器将评估此语句的等效项:
"" eq ""
...其中第一个单词""
不是有效命令。
在 Tcl 语句中,第一个单词必须始终是命令。命令 arg arg arg...
您缺少的是expr
在开始时使用命令
expr {"" eq ""} --> 1
expr {[info procs not_there] eq ""} --> 1
顺便说一句,语句expr
的条件参数中隐含了:if
if {[info procs not_there] eq ""} {
puts "This is not a proc"
}
推荐阅读
- reactjs - D3刷和放大反应
- java - Spring无法构造接口模型的实例
- coldfusion - 将 CFMAIL 转换为等效脚本并使用查询
- email - 电子邮件不会在经典 ASP 中发送,但我永远不会出错
- java - 单元测试时如何跳过@PostConstruct
- python - 将 google-auth 与 gspread 一起使用时,“'Credentials' 对象没有属性 'access_token'”
- arrays - Lambda 表达式不起作用
- diff - How can you get the font size to persist in P4Merge on Windows?
- redis - redis 集群设置并没有在所有节点上发生
- python - 在 windows 中的 python 3.7 上安装 django 时出现代理错误