In order to enable efficient compilation of arithmetic expressions, ECLiPSe imposes the following restriction on their dynamicity: If an expression contains an internal variable (ie. not the whole expression is a variable), this variable must not be bound to another arithmetic expression, but only to numbers. E.g. in the following code p/1 will only work when called with a numerical argument, else it will raise error 24:
On the other hand, q/1 may be called with arbitrary expressions, since Expr does not occur as part of another expression.p(Expr) :- Res is 1 + Expr, ... q(Expr) :- Res is Expr, ...