Category:Tcl: Difference between revisions

m
update current version
(bnf param)
m (update current version)
 
(11 intermediate revisions by 5 users not shown)
Line 17:
{{language programming paradigm|Imperative}}
{{language programming paradigm|Object-oriented}}
{{language programming paradigm|Procedural}}
{{language programming paradigm|Reflective}}
{{Codepad}}
 
'''Tcl''' (short for '''T'''ool '''C'''ommand '''L'''anguage)
'''Tcl''' (short for '''T'''ool '''C'''ommand '''L'''anguage) is a scripting language with very simple syntax, dynamic typing, automatic storage allocation and [[garbage collection]] and native Unicode support. '''Tcl''' is often combined with the [[Tk]] library. As a result, it is often referred to as '''Tcl/Tk'''.
is a scripting language with very simple syntax, dynamic typing,
automatic storage allocation and [[garbage collection]]
and native Unicode support. <br>
'''Tcl''' is often combined with the [[Tk]] library,
which provides support for graphics and GUI. <br>
As a result, it is often referred to as '''Tcl/Tk'''.
 
Tcl is known to be supported under a variety of popular operating systems, including [[UNIX]], [[Linux]], [[BSD]], [[Windows]], [[WinCE]], [[PocketPC]], [[Mac OS X]] and [[BeOS]]. Tcl is distributed under the [[wp:BSD licenses|BSD License]].
including [[UNIX]], [[Linux]], [[BSD]], [[Windows]], [[WinCE]], [[PocketPC]],
[[Mac OS X]] and [[BeOS]]. <br>
Tcl is distributed under the [[wp:BSD licenses|BSD License]].
 
;Current version: Tcl/Tk 8.6.10 (Nov 21, 2019)
The Tcl language has been implemented in multiple lower-level languages. The most common one is '''[[libtcl]]''', written in [[C]], which is the engine used to power [[tclsh]] and [[wish]], but others exist. Notably, these include [[Jacl]] and [[Eagle]], which implement Tcl in [[Java]] and [[C sharp|C#]] respectively.
 
The Tcl language has been implemented in multiple lower-level languages.
The most common one is '''[[libtcl]]''', written in [[C]], which is
the engine used to power [[tclsh]] and [[wish]], but others exist.
Notably, these include [[Jacl]] and [[Eagle]], which implement
Tcl in [[Java]] and [[C sharp|C#]] respectively.
 
Its creator, John Ousterhout, wrote about it:
:''“I got the idea for Tcl while on sabbatical leave at DEC's Western Research Laboratory in the fall of 1987. I started actually implementing it when I got back to Berkeley in the spring of 1988; by summer of that year it was in use in some internal applications of ours, but there was no Tk. The first external releases of Tcl were in 1989, I believe. I started implementing Tk in 1989, and the first release of Tk was in 1991.”''
 
The principal pre-built distributions of Tcl are all based on [[libtcl]]; the main ones are [http://www.activestate.com/activetcl/ ActiveTcl] from ActiveState, and [[tclkit]] from Equi4 Software ''et al''. Older versions of the language are distributed as part of Apple's OSX and all Linux distributions.
the main ones are - besides those in the repositories of Linux and BSD Unices, which are usually current - [[ActiveTcl]] from ActiveState (for several platforms including Windows), BAWT http://www.bawt.tcl3d.org/ (for several platforms including Windows and Mac), Magicsplat http://www.magicsplat.com/tcl-installer/index.html (Windows),
and [[tclkit]] from Equi4 Software ''et al''. <br>
Older versions of the language (8.5) are distributed as part of Apple's OS X.
 
==Language Syntax==
===Grammar===
Note that this is a simplified language grammar, and it is normal to think of the language at a higher level where these differences don't show.
to think of the language at a higher level where these differences don't show.
<br clear=all>
script '''::=''' command'''? ((''' “''\n''” '''|''' “'';''” ''')''' script ''')'''
Line 84 ⟶ 104:
:Generate an error exception. The additional optional arguments allow finer control over the exception.
'''eval''' ''arg''...
:Concatenate the arguments and evaluate the resulting string as a script. Note that from Tcl 8.5 onwards, this should only be used very rarely; the expansion syntax covers the vast majority of previous uses for <tt>'''eval</tt>.'''.
'''list''' ''arg''...
:Create a list out of the arguments and return it. The resulting list is also guaranteed to be a well-formed script that will evaluate the sequence of arguments as a command and arguments without further substitution, making the '''list''' command useful for predictable code synthesis.
'''proc''' ''name formalArgs body''
:Define a new command called ''name'' that pushes a new stack frame, accepts arguments and binds them to the list of local variable names given in ''formalArgs'' and then evaluates ''body''.
Line 95 ⟶ 117:
'''uplevel''' ?''level''? ''arg''...
:Concatenate the arguments and evaluate them as a script in the stack frame given by ''level'' (or the stack frame that called the current procedure if that is omitted). Due to syntactic ambiguities, it is recommended that the ''level'' always be specified explicitly.
==== From Tcl 8.5 ====
'''apply''' ''lambdaTerm arg…''
:Applies a lambda term to zero or more arguments. Lambda terms are two- or three-element tuples, the first element being the formal parameter description, the second being the script that implements the lambda (just as with '''proc''') and the optional third being the context namespace (with the default being the global namespace).
'''dict''' ''subcommand'' …
:Manipulates dictionaries, values that describe a (sparse) mapping from arbitrary keys to arbitrary values (well, so long as both are themselves values).
==== From Tcl 8.6 ====
'''coroutine''' ''name command arg…''
:Create a coroutine called ''name'', which is implemented by the execution of ''command'' together with any supplied arguments. The ''name'' is the name of a command that will be used to resume the coroutine.
'''yield''' ?''value''?
:Yield from a coroutine, with optional value (empty if not supplied). Result will be the optional resumption argument to the coroutine's command.
'''tailcall''' ''command arg…''
:Stops the execution of the current context and replaces it with a call to the given ''command'' with any arguments.
'''oo::class create''' ''name body''
:Creates a class called ''name'' with definition ''body''. Instances of ''name'' are created with “''name'' '''new''' ''arg…''” and “''name'' '''create''' ''instanceName arg…''”. (Note that the syntax for '''oo::class''' is a consequence of this.)
 
==Language Semantics==
Line 118 ⟶ 154:
 
==External Links==
*[http://www.tcl-lang.tkorg/man/ Tcl Documentation]
*[http://wiki.tcl-lang.tkorg Tcl Wiki]
*[http://en.wikipedia.org/wiki/Tcl Wikipedia article]
*[http://en.wikibooks.org/wiki/Programming:Tcl Wikibook]
 
==Todo==
[[Reports:Tasks_not_implemented_in_Tcl]]
Anonymous user