Tcl 教程
Tcl Tutorial

原始链接: https://www.tcl-lang.org/man/tcl8.5/tutorial/tcltutorial.html

本Tcl教程涵盖了广泛的主题,从基本的语法开始,例如打印文本、变量赋值以及使用""、{}和[]的不同引用机制。它深入探讨了诸如使用`if`和`switch`进行数值和文本比较等基本编程概念,并介绍了使用`while`和`for`的循环。 教程解释了如何使用`proc`定义新的命令,包括参数处理以及使用`global`和`upvar`进行作用域管理。然后,它转向诸如列表和关联数组(字典)之类的各种数据结构,并演示了如何操作它们。 字符串操作得到了广泛的介绍,包括模式匹配(“globbing”)、字符串子命令(长度、索引等)、字符串比较、修改和正则表达式。教程还讲解了文件访问、子进程调用以及如何获取有关命令、变量和Tcl解释器本身的信息。 最后,它涉及到使用`source`、包和命名空间进行模块化,以及更高级的主题,例如动态创建命令、调试、处理错误、命令行参数、通道I/O和子解释器。

Hacker News 上的一个帖子讨论了 Tcl 教程及其相关性。antirez 重点介绍了他的小型 Tcl 解释器 Picol,将其作为学习资源。评论者指出 Tcl 在 MacPorts(包管理器)和 Linux 应用程序中的历史用途,并赞扬其比现代 Java 或 Electron 应用程序更精简。讨论涉及 MacPorts 与 Homebrew 的比较,一些人认为尽管 Homebrew 更受欢迎,但 MacPorts 更符合标准。Expect,一个用于自动化的 Tcl 模块,也被提及。其他人分享了他们使用 Tcl 的经验,尤其是在电子设计自动化 (EDA) 领域,Tcl 在该领域仍然占据主导地位。他们还比较了 Tcl、Perl 和 Lua 的嵌入式特性,指出 Tcl 的可读性和易于扩展性。最近发布的 Tcl/TK 9 也被提及,同时人们也希望有一个好的 GUI 设计器。最后,还讨论了一个旨在为 Tcl 提供语言服务器协议 (LSP) 支持的项目。

原文
Tcl Tutorial
  1. Introduction
  2. Running Tcl
  3. Simple Text Output
  4. Assigning values to variables
  5. Evaluation & Substitutions 1: Grouping arguments with ""
  6. Evaluation & Substitutions 2: Grouping arguments with {}
  7. Evaluation & Substitutions 3: Grouping arguments with []
  8. Results of a command - Math 101
  9. Computers and Numbers
  10. Numeric Comparisons 101 - if
  11. Textual Comparison - switch
  12. Looping 101 - While loop
  13. Looping 102 - For and incr
  14. Adding new commands to Tcl - proc
  15. Variations in proc arguments and return values
  16. Variable scope - global and upvar
  17. Tcl Data Structures 101 - The list
  18. Adding & Deleting members of a list
  19. More list commands - lsearch, lsort, lrange
  20. Simple pattern matching - "globbing"
  21. String Subcommands - length index range
  22. String comparisons - compare match first last wordend
  23. Modifying Strings - tolower, toupper, trim, format
  24. Regular Expressions 101
  25. More Examples Of Regular Expressions
  26. More Quoting Hell - Regular Expressions 102
  27. Associative Arrays
  28. More On Arrays - Iterating and use in procedures
  29. Dictionaries
  30. File Access 101
  31. Information about Files - file, glob
  32. Invoking Subprocesses from Tcl - exec, open
  33. Learning the existence of commands and variables ? - info
  34. State of the interpreter - info
  35. Information about procs - info
  36. Modularization - source
  37. Building reusable libraries - packages and namespaces
  38. Creating Commands - eval
  39. More command construction - format, list
  40. Substitution without evaluation - format, subst
  41. Changing Working Directory - cd, pwd
  42. Debugging & Errors - errorInfo errorCode catch error return
  43. More Debugging - trace
  44. Command line arguments and environment strings
  45. Leftovers - time, unset
  46. Channel I/O: socket, fileevent, vwait
  47. Time and Date - clock
  48. More channel I/O - fblocked & fconfigure
  49. Child interpreters
联系我们 contact @ memedata.com