Version 10 of procedure

Updated 2021-06-22 16:29:28 by pooryorick

A procedure is a routine that has a name that can be used as the first word in a command. proc creates a new procedure, and so do the C functions Tcl_CreateObjCommand() and friends. info commands provides a list of available procedures, and info procs provides a list of available procedures that were created by proc.

Description

A procedure has name in a certain namespace, and can only be found when that namespace is in the resolution path. When a procedure is called, a new level is created to hold the variables local to that call, and that namespace current namespace becomes the current namespace. Arguments to the procedure are available as variables at in the new level.

See global or variable or upvar on how to "import" variables from upper scopes.

A procedure is like a function in that it always returns a value. When the purpose of a procedure is only to produce a side effect, its value is usually the empty string. If there is no explicit return, then the value of the last command is the value of the procedure.

Page Authors

RS
PYK