【发布时间】:2020-04-18 06:57:14
【问题描述】:
使用 init.tcl 我们改进了时钟命令以供国际使用。这工作正常,直到我尝试使用时钟命令初始化包中的变量。一个简单的包,如:
package provide mylib [lindex {Revision: 1.0 } 1]
namespace eval mylib {
set X [clock format [clock seconds] -format %y%m%d]
proc naught {} {
variable X
puts $X
return
}
}
当我运行 pkg_mkIndex 时,我得到: 警告:采购 mylib.pkg 时出错:导入模式“::msgcat::mcload”中的未知命名空间
修改后的时钟命令 -clock.tcl - 使用 msgcat 包,如: 上层 #0 { 包需要 msgcat 1.6.1 如果我添加 puts "PKG: [package require msgcat 1.6.1]" 之类的 puts,它会返回空字符串而不是版本
当然clock.tcl是从init.tcl调用的 我在 pkg_mkIndex 代码中注意到以下内容:
$c eval {
# Stub out the package command so packages can require other
# packages.
rename package __package_orig
proc package {what args} {
switch -- $what {
require {
return; # Ignore transitive requires
}
default {
__package_orig $what {*}$args
}
}
}
这可以解释为什么没有加载 msgcat 包。
如何从 clock.tcl 过程中加载 msgcat 包?
【问题讨论】:
标签: tcl