Overview Module Function Class Tea 3.1.0 Reference Documentation
© 2002 PDM&FC

Function define

define varName value
define functionName formalArgs body

Creates a variable in the current context.

Parameters:
varName - Symbol identifying the variable to be created in the current context.
value - The object for wich the variable will hold a reference.
functionName - Symbol identifying the function to be created in the current context.
formalArgs - List of symbols representing the function formal arguments, or a symbol representing the list of formal arguments.
body - Code block object that will be used as the new function body.
Returns:
The contents of the variable, that is, a reference to the value object. In the second case it returns a reference to the function object.

Example of defining a numeric variable:
    define pi 3.141516

Example of defining a square function:
    define square ( x ) { * $x $x }

Example of defining a function which accepts a variable number of arguments:
    define lineEcho argList {
        foreach arg $argList {
            echo $arg
        }
    }

Defining the same variable more than once in the same context is legal. Subsequent definitions only change its value, like performed by the function set!.

Overview Module Function Class Tea 3.1.0 Reference Documentation
© 2002 PDM&FC
Report a bug or request new features
© 2002