This is the final state of the document as it was used for the resolutions in Edinburgh. In the meantime many systems adopted accordingly. This document is superseded by DTC2.In 13211-1:1995 evaluable functors (9) are used for evaluating an expression (7.9) within Arithmetic evaluation (8.6) and Arithmetic comparison (8.7). This document provides an overview of the current practice of evaluable functors that are not part of 13211-1 but are compliant (5.1) due to:
5.5.10 Evaluable functors
A processor may support one or more additional evaluable
functors (9) as an implementation specific feature.
Implementors interested in standardization who wish to see their system listed in this table are asked to provide a table in HTML with the complete first row and one row for their system. If the same function is provided with an alternate name, the entry shall be labelled "alt". Functions added since the Pasadena meeting shall be labelled "new".
core | core | pllib | cuf | B | IF | SICStus | YAP | SWI | ECLiPSe | GNU | |
Functor | 2008-11-17 | 2009-07-17 | 7B | 7.3 | V5.3 | 3.12 | 6.0 | 5.7 | 6.0 | 1.3.2 | |
(+)/1 | 9.1 | 9.1 | yes | yes | yes | yes | yes | yes | yes | yes | |
max/2 | 9.3.11 | 9.3.11 | yes | yes | yes | yes | yes | yes | yes | yes | |
min/2 | 9.3.10 | 9.3.10 | yes | yes | yes | yes | yes | yes | yes | yes | |
acos/1 | 9.5.5 | 9.5.5 | yes | yes | yes | yes | yes | yes | yes | yes | |
asin/1 | 9.5.4 | 9.5.4 | yes | yes | yes | yes | yes | yes | yes | yes | |
tan/1 | 9.5.3 | 9.5.3 | yes | yes | yes | yes | yes | yes | yes | new | |
pi/0 | 9.7.1 | 9.7.1 | yes | yes | yes | yes | yes | yes | new | ||
xor/2 | yes | alt | alt | alt | yes | yes | alt | ||||
alt | yes | yes | yes | alt | alt | alt | |||||
9.4.6 | 9.4.6 | alt | alt | alt | alt | new | alt | new | |||
atan2/2 | yes | yes | yes | alt | alt | alt | |||||
9.5.6 | 9.5.6 | alt | alt | alt | new | yes | new | ||||
(^)/2 | new | any | yes | yes | yes | yes | new | ||||
(div)/2 | yes | yes | new | yes | |||||||
e/0 | 9.7.2 | 9.7.2 | yes | yes | yes | yes | yes | new | |||
log10/1 | yes | yes | new | ||||||||
msb/1 | yes | yes | yes | new | |||||||
lsb/1 | new | yes | new | ||||||||
popcount/1 | new | yes | new | ||||||||
clrbit/2 | yes | ||||||||||
getbit/2 | yes | ||||||||||
setbit/2 | yes | ||||||||||
log1p/1 | ? | ||||||||||
expm1/1 | ? | ||||||||||
signum/1 | yes | alt | |||||||||
sgn/1 | yes | ||||||||||
gcd/2 | 9.3.9 | 9.3.9 | yes | yes | yes | yes | yes | new | |||
lcm/2 | yes | ||||||||||
eval/1 | yes | yes | |||||||||
nexttoward/2 | yes | ||||||||||
copysign/2 | yes | yes | |||||||||
extensibility | - | - | ? | yes | yes |
1 (#)/2
vs. (><)/2
vs. xor/2
.
(#)/2
is conflicting or irritating w.r.t constraints.
(><)/2
suggests to be something similar to a
relational operator like (>)/2
.
xor/2
says what it is, but isn't an operator.
Adding xor
as operator seems problematic. This
voids Prolog text like (a, b, xor).
2 Original name: atan2/2
vs. replacement atan/2
. In favor of atan2/2: All other
languages/libraries call it atan2. Cannot be confused
with atan/1
of 13211-1:1995.
3 (^)/2
- missing for unbounded integers.
(**)/2
has as result type float only. This is useful for
arguments of type float or bounded integers. But for unbounded
integers the result type should be an unbounded integer. To avoid
compatibility problems a new name seems to be the best.
Also, (**)/2
is declared as op(200,xfx,**).
in the operator table 6.3.4.4. This means that 7**7**7.
is invalid Prolog text, whereas 7^7^7.
is valid with the
correct associativity. ^
is used also in Haskell. An
addition seems to be less problematic than a change.
4 Instead of e
one can write exp(1).
5 div/2 is defined as:
div(X, Y, Z) :- Z is (X - X mod Y) // Y.
signum/1 and sgn/1 always return an integer (-1, 0 or 1).
In ECLiPSe native mode, floor, ceiling, round and truncate always return a result of the same type as the argument.
integer/1 is a pure type conversion (like float/1). It converts its argument to integer type iff it has an integral value. Otherwise it raises an exception. The purpose is to convert the results of sign/1 or float_integer_part/1 (and non-standard versions of round, truncate, floor, ceiling) to integers, if needed.
setbit(X,Y) sets bit Y in X. Bits are counted from 0 (lsb).
div/2 is the division that goes with mod/2, while (//)/2 goes with rem/2.
eval/1 is used to mark variables that may be instantiated to a symbolic expression (rather than a number) at runtime. See this thread in comp.lang.prolog.
In ECLiPSe, any deterministic predicate that returns a number as its last argument can be used as an arithmetic function, e.g. atom_length(hello) will evaluate to 5 via calling atom_length/2. Arguments of such expressions are not recursively evaluated (unless this is done explicitly by the corresponding predicate), and therefore do not need to be arithmetic expressions themselves.
X is contestedarithmeticfunction(A,B).
X > tan(Y)
(>=<)/2
arithmetic comparable>=<(E1, E2)
is true iff the corresponding
evaluated values EV1
and EV2
are comparable
numbers.
(>=<)/2
It succeeds if V1 and V2 are comparable numbers. It fails if V1 and V2 are numbers that are not comparable.
It needs some standardese around to it allow for the possibility that V1, V2, or both might be constrained and the constraints might be such as to determine the order.
This is intended to be the IEEE "?" comparison, but needs to be described so that a Prolog that allows complex numbers (as C99 does, which could be used to implement it) could use it to avoid trying to order complex numbers.
At least one Prolog with rational arithmetic had rational ±infinity and rational NaN, so it would have had a use for this too.