Tcl | |
Logo Alt: | Tcl logo |
Paradigm: | Multi-paradigm |
Designer: | John Ousterhout |
Developer: | Tcl Core Team |
Typing: | Dynamic typing, everything is a string |
Implementations: | ActiveTcl Androwish |
Dialects: | Jim, Eagle |
Influenced By: | AWK, Lisp |
Influenced: | PHP,[1] PowerShell,[2] Tea, TH1[3] |
License: | BSD-style[4] |
Website: | |
File Ext: | .tcl, .tbc[5] |
Tcl (pronounced "tickle" or as an initialism[6]) is a high-level, general-purpose, interpreted, dynamic programming language. It was designed with the goal of being very simple but powerful.[7] Tcl casts everything into the mold of a command, even programming constructs like variable assignment and procedure definition.[8] Tcl supports multiple programming paradigms, including object-oriented, imperative, functional, and procedural styles.
It is commonly used embedded into C applications, for rapid prototyping, scripted applications, GUIs, and testing.[9] Tcl interpreters are available for many operating systems, allowing Tcl code to run on a wide variety of systems. Because Tcl is a very compact language, it is used on embedded systems platforms, both in its full form and in several other small-footprint versions.[10]
The popular combination of Tcl with the Tk extension is referred to as Tcl/Tk (pronounced "tickle teak" or as an initialism) and enables building a graphical user interface (GUI) natively in Tcl. Tcl/Tk is included in the standard Python installation in the form of Tkinter.
The Tcl programming language was created in the spring of 1988 by John Ousterhout while he was working at the University of California, Berkeley.[11] [12] Originally "born out of frustration",[13] according to the author, with programmers devising their own languages for extending electronic design automation (EDA) software and, more specifically, the VLSI design tool Magic, which was a professional focus for John at the time.[14] Later Tcl gained acceptance on its own. Ousterhout was awarded the ACM Software System Award in 1997 for Tcl/Tk.[15]
The name originally comes from Tool Command Language, but is conventionally written Tcl rather than TCL.[16]
Date | Event |
---|---|
January 1990 | Tcl announced beyond Berkeley (Winter USENIX). |
June 1990 | Expect announced (Summer USENIX). |
January 1991 | First announcement of Tk (Winter USENIX). |
June 1993 | First Tcl/Tk conference (Berkeley). [table] geometry manager (forerunner of [grid]), [incr Tcl]]], TclDP and Groupkit, announced there.|-| August 1997 || Tcl 8.0 introduced a bytecode compiler.[17] |-| April 1999 || Tcl 8.1 introduces full Unicode support[18] and advanced regular expressions.[19] |-| August 1999 || Tcl 8.2 introduces Tcl Extension Architecture (TEA)[20] |-| August 2000 || Tcl Core Team formed, moving Tcl to a more community-oriented development model.[21] |-| September 2002 || Ninth Tcl/Tk conference (Vancouver). Announcement of starkit packaging system. Tcl 8.4.0 released.[22] |-| December 2007 || Tcl 8.5 added new datatypes, a new extension repository, bignums,[23] lambdas.[24] [25] |-| December 2012 || Tcl 8.6 added built-in dynamic object system, TclOO, and stackless evaluation.[26] |} Tcl conferences and workshops are held in both the United States and Europe.[27] FeaturesTcl's features include
Safe-TclSafe-Tcl is a subset of Tcl that has restricted features so that Tcl scripts cannot harm their hosting machine or application.[30] File system access is limited and arbitrary system commands are prevented from execution. It uses a dual interpreter model with the untrusted interpreter running code in an untrusted script. It was designed by Nathaniel Borenstein and Marshall Rose to include active messages in e-mail. Safe-Tcl can be included in e-mail when the application/safe-tcl and multipart/enabled-mail are supported. The functionality of Safe-Tcl has since been incorporated as part of the standard Tcl/Tk releases.[31] [32] Syntax and fundamental semanticsThe syntax and semantics of Tcl are covered by twelve rules[33] known as the Dodekalogue.[34] A Tcl script consists of a series of command invocations. A command invocation is a list of words separated by whitespace and terminated by a newline or semicolon. The first word is the name of a command, which may be built into the language, found in an available library, or defined in the script itself. The subsequent words serve as arguments to the command: commandName argument1 argument2 ... argumentN The following example uses the puts (short for "put string") command to display a string of text on the host console: This sends the string "Hello, World!" to the standard output device along with an appended newline character. Variables and the results of other commands can be substituted into strings, such as in this example which uses the set and expr commands to store the result of a calculation in a variable (note that Tcl does not use
set sum [expr 1+2+3+4+5]puts "The sum of the numbers 1..5 is $sum." The
set x 1set sum [expr {$x + 2 + 3 + 4 + 5}]; # $x is not substituted before passing the parameter to expr; # expr substitutes 1 for $x while evaluating the expressionputs "The sum of the numbers 1..5 is $sum."; # sum is 15
set x 2set op *set y 3set res [expr $x$op$y]; # $x, $op, and $y are substituted, and the expression is evaluated to 6puts "$x $op $y is $res."; # $x, $op, $y, and $res are substituted and evaluated as strings As seen in these examples, there is one basic construct in the language: the command. Quoting mechanisms and substitution rules determine how the arguments to each command are processed. One special substitution occurs before the parsing of any commands or arguments. If the final character on a line (i.e., immediately before a newline) is a backslash, then the backslash-newline combination (and any spaces or tabs immediately following the newline) are replaced by a single space. This provides a line continuation mechanism, whereby long lines in the source code can be wrapped to the next line for the convenience of readers. Continuing with normal argument processing, a word that begins with a double-quote character ( In bare and double-quoted words, three types of substitution may occur:
Substitution proceeds left-to-right in a single scan through each word. Any substituted text will not be scanned again for possible further substitutions. However, any number of substitutions can appear in a single word. From Tcl 8.5 onwards, any word may be prefixed by As a consequence of these rules, the result of any command may be used as an argument to any other command. Note that, unlike in Unix command shells, Tcl does not reparse any string unless explicitly directed to do so, which makes interactive use more cumbersome, but scripted use more predictable (e.g., the presence of spaces in filenames does not cause difficulties). The single equality sign ( The majority of Tcl commands, especially in the standard library, are variadic, and the Tcl is not statically typed: each variable may contain integers, floats, strings, lists, command names, dictionaries, or any other value; values are reinterpreted (subject to syntactic constraints) as other types on demand. However, values are immutable and operations that appear to change them actually just return a new value instead. Basic commandsThe most important commands that refer to program execution and data operations are:
The usual execution control commands are:
Those above looping commands can be additionally controlled by the following commands:
Advanced commands
Uplevel
It was originally implemented to permit Tcl procedures to reimplement built-in commands (like for, if or while) and still have the ability to manipulate local variables. For example, the following Tcl script is a reimplementation of the for command (omitting exception handling): Upvar
A decr command that works like the built-in Object-orientedSee also: Object-oriented programming. Tcl 8.6 added a built-in dynamic object system, TclOO, in 2012. It includes features such as:
Tcl did not have object oriented (OO) syntax until 2012, so various extension packages emerged to enable object-oriented programming. They are widespread in existing Tcl source code. Popular extensions include: TclOO was not only added to build a strong object oriented system, but also to enable extension packages to build object oriented abstractions using it as a foundation. After the release of TclOO, incr Tcl was updated to use TclOO as its foundation. Web application developmentTcl Web Server is a pure-Tcl implementation of an HTTP protocol server. It runs as a script on top of a vanilla Tcl interpreter. Apache Rivet is an open source programming system for Apache HTTP Server that allows developers to use Tcl as a scripting language for creating dynamic web applications. Rivet is similar to PHP, ASP, and JSP. Rivet was primarily developed by Damon Courtney, David Welton, Massimo Manghi, Harald Oehlmann and Karl Lehenbauer. Rivet can use any of the thousands of publicly available Tcl packages that offer countless features such as database interaction (Oracle, PostgreSQL, MySQL, SQLite, etc.), or interfaces to popular applications such as the GD Graphics Library. Interfacing with other languagesTcl interfaces natively with the C language.[37] This is because it was originally written to be a framework for providing a syntactic front-end to commands written in C, and all commands in the language (including things that might otherwise be keywords, such as Digital logic simulators often include a Tcl scripting interface for simulating Verilog, VHDL and SystemVerilog hardware languages. Tools exist (e.g. SWIG, Ffidl) to automatically generate the necessary code to connect arbitrary C functions and the Tcl runtime, and Critcl does the reverse, allowing embedding of arbitrary C code inside a Tcl script and compiling it at runtime into a DLL. Extension packagesThe Tcl language has always allowed for extension packages, which provide additional functionality, such as a GUI, terminal-based application automation, database access, and so on. Commonly used extensions include:
See also
Further reading
External links
|