Version 8 of Tcl procedure

Updated 2008-06-26 19:34:13 by lars_h

Some of Tcl's documentation refers to procedures as a distinct type of command.

A procedure is a Tcl command that is created by the proc command.

For example the info args command expects its argument to be the name of a procedure. Names of other commands passed to info args will cause an error to be raised.


Some languages (e.g. Pascal) uses the terms "function" and "procedure" to denote subroutines which do and don't respectively return a value. In Tcl, the distinction is quite different: a function is a subroutine available in expressions (and as of Tcl 8.5 these are merely implemented by commands in the tcl::mathfunc namespace). A procedure is a command created by proc, and like any other command it returns a value. In the absence of an explicit return, this value is simply the value returned by the last command in the procedure body.


see also Pass by reference and Implicit upvar.