prog
prog(l_localVariables[ [s_label]g_expr1] ... ) =>g_result/nil
Description
Allows for local variable bindings and permits abrupt exits on control jumps. This is a syntax form.
The first argument to prog is a list of variables declared to be local within the context of the prog. The expressions following the prog are executed sequentially unless one of the control transfer statements such as go or return is encountered. A prog evaluates to the value of nil if no return statement is executed and control simply “falls through” the prog after the last expression is executed. If a return is executed within a prog, the prog immediately returns with the value of the argument given to the return statement.
Any statement in a prog can be preceded by a symbol that serves as a label for the statement. Unless multiple return points are necessary or you are using the go function, a faster construct for binding local variables, let, should be used over prog.
Arguments
Value Returned
Examples
x = "hello"
=> "hello"
prog( (x y) ; Declares local variables x and y.
x = 5 ; Initialize x to 5.
y = 10 ; Initialize y to 10.
return( x + y )
)
=> 15
x
=> "hello" ; The global x keeps its original value.
Related Topics
Function and Program Structure
Return to top