Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

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

l_localVariables

List of variables local to prog.

s_label

Labels a statement inside a prog; labels can be defined only for statements at the top level. Statements nested inside another statement cannot be labeled unless the surrounding statement is itself a prog.

g_expr1

Any SKILL expression to be evaluated inside the prog.

Value Returned

g_result

Value of the return statement if one is used.

nil

Otherwise always returns nil.

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

let

progn


Return to top
 ⠀
X