TCL A Universal Scripting Language
TCL A Universal Scripting Language
John Ousterhout
Sun Microsystems Laboratories
john.ousterhout@eng.sun.com
http://www.sunlabs.com/~ouster
Introduction
Outline
An example:
Tcl: universal scripting language.
Tk: GUI toolkit based on Tcl.
Language rationale:
Unusual design goals (e.g. extensibility).
Key features:
Unstructured (everything's a string).
No grammar.
Quote by default.
Substitutions.
Substitutions:
set b $a
set b [expr $a+10]
47
57
Quoting:
set b "a is $a"
a is 47
set b {[expr $a+10]} [expr $a+10]
Procedures.
Access to UNIX files, subprocesses.
Only representation is strings:
Easy access from C.
Programs and data interchangeable.
Factorial Procedure
proc fac x {
if $x<=1 {return 1}
expr $x*[fac [expr $x-1]]
}
fac 4
24
Tcl
Application
Init
Parser
Command
Loop
Built-In
Commands
Application
Commands
Extensions
Init
Parser
Command
Loop