[ ECLiPSe Arithmetic built-in.|Group Index|
Full Index]
eval(+Expression, ?Result)
Used to evaluate eval/1 terms in arithmetic expressions. It is equivalent
to Result is Expression, which should be preferred for direct use.
- +Expression
- An arithmetic expression.
- ?Result
- A variable or a number.
Description
This s 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 (non-coroutine mode only). Error 5 --- Result is neither a number nor a variable.
- (5) Type error
- Evaluation of Expression gives a different type than Result.
- (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, ECLiPSe manual chapter on arithmetic