1 / 8

Tcl Scripting Language

Tcl Scripting Language. By Alan Andrews CS354 Spring 2008. History. Developed by John at the University of California, Berkley in 1988 Ousterhout left for Sun in 1994 to fully develop Tcl. In 1998, Ousterhout started his own company, Scriptics, to continue to support Tcl.

Download Presentation

Tcl Scripting Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tcl Scripting Language By Alan Andrews CS354 Spring 2008

  2. History • Developed by John at the University of California, Berkley in 1988 • Ousterhout left for Sun in 1994 to fully develop Tcl. • In 1998, Ousterhout started his own company, Scriptics, to continue to support Tcl. • Tcl, now, maintained by internet group called Tcl Core Team

  3. Tcl Features • Language can be embedded in any C/C++ application • Procedural, scripting language • Every line must begin with command • Variables passed by value • Simple exception handling supported • Loosely-typed language (everything is treated as a string unless the context calls for a number)

  4. Syntax • Syntax for all commands are: • command arg1 arg2 arg3 … • Spaces can be included in arguments by enclosing value in double-quotes “” or curly brackets {}. • Variables are set using the “set” command: • setvarvalue • Variables are dereferenced using “$” character: • $var • Command substitution occurs in square brackets []. • All arrays are “associative” arrays. • Arrays look like “$arrayValue(key) -> value” • To set array: • setarrayValue(key) value • Mathematical operations are preceded with the command expr • expr5 + (4 / 3) * sin(3.14/2)

  5. Common Examples • Declare new procedure procprocName {arg1} { … return $value } • If statement if {boolExpression} { … } else { … } • While loop while {boolExpression} { … }

  6. Common Examples • For loop for {initialize} {boolExpression} {iterativeStep} { … } • Foreach loop foreachvarName list { … } • Switch statement switchvalue { valueMatch1 {…} valueMatch2 {…} … default {…} }

  7. Analysis • Readability • Easy to read as all commands contain a similar syntax, including regular programming constructs like if statements, while statements, etc. • Writability • All commands follow the same syntax, so all that is required is knowing where each argument should be given. • Performing many math functions tend to get a bit unwieldy. • Reliability • Lack of type-checking can cause problems when, for example, a non-boolean value is given inside of an “if” statement • Tcl’s inclusion of scope-modifying commands can cause headaches when used liberally. • “upvar” can access, manipulate, or delete any variables declared in the call-stack.

  8. Tcl Command Reference • http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm

More Related