如何在tcl中使用不同版本的包中的程序
我的问题是我创建了两个版本,即 1.1 1.2 包 我在 1.1 和 1.2 中有相同的程序,但我在 1.2 中修改了新版本的程序。
现在我的问题是想访问旧版本(1.1)程序。我怎么办?
My question is i have created two versions that is 1.1 1.2 packages
i have same procedures in 1.1 and 1.2 but i modified a new version of procedure in 1.2.
Now my question is suppose to want acess old version (1.1) procedure. How i do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每个解释器只能加载任何特定包的单个版本;假设它们的命名空间发生冲突,因此不可能同时加载同一事物的两个版本。
但是,您可能能够在子解释器中加载其他版本(使用
-exact
选项强制使用较新的版本)。与具有 C 组件的包相比,这更有可能适用于纯脚本包(这取决于操作系统的动态库加载器对这些东西是否满意;有些是,有些不是。)这可能是也可能不是您想要的不过之后;解释器彼此之间非常隔离,因此访问主解释器中发生的其他事情需要设置别名......
Each interpreter can only load a single version of any particular package; it's assumed that their namespaces clash so that it isn't possible to load two versions of the same thing at once.
However, you might be able to load the other version (using the
-exact
option to force the less-recent version) in a sub-interpreter. This is more likely to work with pure scripted packages than those which have a C component (that depends on the OS's dynamic library loader being happy with these things; some are, some aren't.)This might or might not be what you're after though; interpreters are very strongly isolated from each other, so access to other things going on in the master interpreter would require setting up aliases…
在包 require 语句中使用 -exact 标志:
更新:
我不建议相继加载同一包的不同版本。但是,您可以加载第一个版本,执行您的业务,卸载它,然后加载第二个版本并执行您的业务。在代码中:
Use the -exact flag in the package require statement:
UPDATE:
I don't recommend having different versions of the same package loaded one after another. However, you can load the first version, do your business, unload it, then load the second version and do your business. In code: