没有合适的资源?快使用搜索试试~ 我知道了~
首页Tcl/Tk入门经典(第2版):高效开发与代码规范
Tcl/Tk入门经典(第2版):高效开发与代码规范
需积分: 9 1 下载量 132 浏览量
更新于2024-07-18
收藏 73KB PDF 举报
"Tcl_Tk入门经典(第2版)"是一本专注于Tcl脚本语言开发的指南,特别针对那些在Wish或其他Tcl应用环境中工作的开发者设计。该书强调了一套编程规范,旨在确保代码质量、一致性以及高效性。以下是主要内容的详细介绍: 1. 代码规范:书中规定了编写Tcl代码时应遵循的规则,例如,每个函数或命令必须有明确的文档说明,包括参数的描述和预期的结果。这些规范确保了代码的可读性和可维护性,使得团队成员能更容易地理解彼此的工作。 2. 测试与实践:书中强调了编写测试脚本的重要性,每个代码行都应该有相应的测试案例,以验证其功能和行为。这有助于尽早发现并修复潜在问题,提升代码的健壮性。 3. 风格统一:通过遵循特定的编码风格,Tcl和Tk代码将具有一致的外观和结构,这对于团队协作非常关键,能够减少误解和潜在冲突。 4. 避免常见错误:规范还限制了一些可能引发错误的编程习惯,例如鼓励使用内置的列表构建方法而非手动创建,这样可以减少出错的可能性,提高代码的效率。 5. 基于实践的指导:本书深受John Ousterhout的《Tcl/Tk工程手册》的影响,后者详细规定了Tcl/Tk实现和扩展的C代码风格,是本书的重要参考资料。尽管TclStyleGuide主要关注的是Tcl脚本层面,但其背后的理念和原则同样适用于Tk编程,甚至对于理解和优化整个Tcl/Tk环境都具有价值。 "Tcl_Tk入门经典(第2版)"不仅提供了Tcl和Tk的基础知识,更是通过一套严谨的编程规范和实践策略,帮助开发者提升代码质量和工作效率,是Tcl开发者不可多得的参考文献。
资源详情
资源推荐
![](https://csdnimg.cn/release/download_crawler_static/10854020/bg3.jpg)
Tcl Style Guide August 22, 1997 3
3. Packages and namespaces
Tcl applications consist of collections of packages. Each package provides code to implement
a related set of features. For example, Tcl itself is a package, as is Tk; these packages happen
to be implemented in both C and Tcl. Other packages are implemented completely in Tcl such
as the http package included in the Tcl distribution. Packages are the units in which code is
developed and distributed: a single package is typically developed by a single person or group
and distributed as a unit. It is possible to combine many independently-developed packages
into a single application; packages should be designed with this in mind. The notion of
namespaces were created to help make this easier. Namespaces help to hide private aspects of
packages and avoid name collisions. A package will generally export one public namespace
which will include all state and routines that are associated with the package. A package
should not contain any global variables or global procedures. Side effects when loading a pack-
age should be avoided. This document will focus on packages written entirely in Tcl. For a dis-
cussion of packages built in C or C and Tcl see the Tcl/Tk Engineering Manual.
3.1 Package names
Each package should have a unique name. The name of the package is used to identify the
package. It is also used as the name of the namespace that the package exports. It is best to
have a simple one word name in all lower-case like http. Multi-word names are ok as well.
Additional words should just be concatenated with the first word but start with a capital letter
like specMenu.
Coming up with a unique name for your package requires a collaborative component. For
internal projects this is an easy task and can usually be decided among the management or
principal engineers in your organization. For packages you wish to publish, however, you
should make an effort to make sure that an existing package isn’t already using the same name
you are. This can often be done by checking the comp.lang.tcl newsgroup or the standard Tcl
ftp sites. It is also suggested (but not required) that you register your name on the NIST Identi-
fier Collaboration Service (NICS). It is located at: http://pitch.nist.gov/nics
3.2 Version numbers
Each package has a two-part version number such as 7.4. The first number (7) is called the
major version number and the second (4) is called the minor version number. The version num-
ber changes with each public release of the package. If a new release contains only bug fixes,
new features, and other upwardly compatible changes, so that code and scripts that worked
with the old version will also work with the new version, then the minor version number incre-
ments and the major version number stays the same (e.g., from 7.4 to 7.5). If the new release
contains substantial incompatibilities, so that existing code and scripts will have to be modified
to run with the new version, then the major version number increments and the minor version
number resets to zero (e.g., from 7.4 to 8.0).
3.3 Package Namespaces
As of version 8.0, Tcl supports namespaces to hide the internal structure of a package. This
helps avoid name collisions and provides a simpler way to manage packages. All packages
written for Tcl 8.0 or newer should use namespaces. The name of the name space should be the
same as the package name.
3.4 Structure
There are a couple of ways to deploy a package of Tcl commands.
• A pkgIndex.tcl file is used to create packages that can be loaded on demand by any Tcl
script. Like a tclIndex file, a package specifies a set of Tcl and/or shared libraries that
剩余14页未读,继续阅读
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://profile-avatar.csdnimg.cn/bac1d9794319478dac016e6176a5ef52_u011368447.jpg!1)
csd_murphy
- 粉丝: 34
- 资源: 22
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![](https://csdnimg.cn/release/wenkucmsfe/public/img/voice.245cc511.png)
最新资源
- 构建Cadence PSpice仿真模型库教程
- VMware 10.0安装指南:步骤详解与网络、文件共享解决方案
- 中国互联网20周年必读:影响行业的100本经典书籍
- SQL Server 2000 Analysis Services的经典MDX查询示例
- VC6.0 MFC操作Excel教程:亲测Win7下的应用与保存技巧
- 使用Python NetworkX处理网络图
- 科技驱动:计算机控制技术的革新与应用
- MF-1型机器人硬件与robobasic编程详解
- ADC性能指标解析:超越位数、SNR和谐波
- 通用示波器改造为逻辑分析仪:0-1字符显示与电路设计
- C++实现TCP控制台客户端
- SOA架构下ESB在卷烟厂的信息整合与决策支持
- 三维人脸识别:技术进展与应用解析
- 单张人脸图像的眼镜边框自动去除方法
- C语言绘制图形:余弦曲线与正弦函数示例
- Matlab 文件操作入门:fopen、fclose、fprintf、fscanf 等函数使用详解
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035711.png)
![](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![](https://csdnimg.cn/release/wenkucmsfe/public/img/green-success.6a4acb44.png)