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

eval

eval( 
g_expression 
[ e_environment ] 
) 
=> g_result

Description

Evaluates an argument and returns its value. If an environment argument is given, g_expression is treated as SKILL++ code, and the expression is evaluated in the given (lexical) environment. Otherwise g_expression is treated as SKILL code.

This function gives you control over evaluation. If the optional second argument is not supplied, it takes g_expression as SKILL code. If an environment argument is given, it treats g_expression as SKILL++ code, and evaluates it in the given (lexical) environment.

For SKILL++'s eval, if the given environment is not the top-level one, the effect is like evaluating g_expression within a let construct for the bindings in the given environment, with the following exception:

If g_expression is a definitional form (such as (define ...)), it is treated as a global definition instead of local one. Therefore any variables defined will still exist after executing the eval form.

Arguments

g_expression

Any SKILL expression.

e_environment

If this argument is given, SKILL++ semantics is assumed. The forms entered will be evaluated within the given (lexical) environment.

Value Returned

g_result

Result of evaluating g_expression.

Examples

Evaluates the expression plus(2 3).

eval( 'plus( 2 3 ) )    => 5

Evaluates the symbol x and returns the value of symbol x.

x = 5                    => 5
eval( 'x )   => 5

Evaluates the expression max(2 1).

eval( list( 'max 2 1 ) ) => 2

Related Topics

Function and Program Structure

evalstring


Return to top
 ⠀
X