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

return

return( 
[ g_result ] 
) 
=> g_result / nil 

Description

Forces the enclosing prog to exit and returns the given value. The return statement has meaning only when used inside a prog statement.

Both go and return are not purely functional in the sense that they transfer control in a non-standard way. That is, they don’t return to their caller.

Arguments

g_result

Any SKILL object.

Value Returned

The enclosing prog statement exits with the value given to return as the prog’s value. If return is called with no arguments, nil is returned as the enclosing prog’s value.

Examples

procedure( summation(l)
prog( (sum temp)
sum = 0
temp = l
while( temp
if( null(car(temp))
then
return(sum)
else
sum = sum + car(temp)
temp = cdr(temp)
)
)
)
)

Returns the summation of previous numbers if a nil is encountered.

summation( '(1 2 3 nil 4)) 
=> 6   ; 1+2+3
summation( '(1 2 3 4)) 
=> nil   ; prog returns nil if no explicit return)

Related Topics

Flow Control Functions

nlambda

go


Return to top
 ⠀
X