[ Arithmetic | The ECLiPSe Built-In Predicates | Reference Manual | Alphabetic Index ]
eval(+Expression, ?Result)
Used to evaluate eval/1 terms in arithmetic expressions.
- +Expression
- An arithmetic expression.
- ?Result
- A variable or a number.
Description
This is one of the predicates used by the ECLiPSe compiler to expand
arithmetic expressions. If an expression contains a subexpression that
is not known at compile time, it must be wrapped in eval/1, e.g.
X is eval(Expr)+1
This will be compiled into the sequence
eval(Expr,T1), +(T1,1,X)
and eval/2 will interpret the expression Expr at runtime.
Fail Conditions
Fails if the result of the evaluation does not unify with Result or if a
user-defined evaluation predicate fails.
Resatisfiable
No
Exceptions
- (4) instantiation fault
- Expression is uninstantiated.
- (5) type error
- Result is neither a number nor a variable.
- (5) type error
- Evaluation of Expression gives a different type than Result.
- (21) undefined arithmetic expression
- An evaluation predicate in the expression is not defined.
- (24) number expected
- Expression is not a valid arithmetic expression.
Examples
See Also
is / 2, + / 2, - / 2, abs / 2, sgn / 2, ceiling / 2, floor / 2, round / 2, + / 3, - / 3, * / 3, / / 3, // / 3, mod / 3, ^ / 3, min / 3, max / 3, \ / 2, /\ / 3, \/ / 3, xor / 3, >> / 3, << / 3, clrbit / 3, getbit / 3, setbit / 3, sin / 2, cos / 2, tan / 2, asin / 2, acos / 2, atan / 2, exp / 2, ln / 2, sqrt / 2, fix / 2, float / 2, rational / 2, numerator / 2, denominator / 2