Tcl Syntax

Here are the basics of Tcl syntax.

Comments

Comments in Tcl are lines that start with a ``#''. They are taken care of by the Tcl interpreter.

Words

Words are bits of code that are separated by spaces and newlines, so there five words below: commandOne arg1 arg2 commandTwo arg3

Commands

Commands are sequences of words that are separated by semicolons or newlines, so there are three commands below, and seven words: commandOne arg1 arg2 ; commandTwo arg3 arg4 commandThree Note that commands are rarely split using semicolons.

The Interpreter

Basically, the Tcl interpreter contains a table that associates commands strings that are seen in the source code (such as if, while etc.) and a pointer to the C function that implements it.

Once the Tcl interpreter has broken down the source into commands, it looks up the first word of the command in a table, and calls the associated function with the rest of the words for arguments.


Previous Contents Next
Clinton Roy