The documentation of mathematical functions, and the declarations of operators is inconsistent and confusing.
mod is documented with +IntExpr1 mod +IntExpr2, and current_op(_,_,mod) is true. gcd is documented with +IntExpr1 gcd +IntExpr2, but current_op(_,_,gcd) is false. div is documented with div(+IntExpr1, +IntExpr2), yet current_op(_,_,div) is true.
It occurred to me that gcd not being an operator might have something to do with the fact that it’s not an ISO function. However
rdiv is not ISO, is documented with +IntExpr1 gcd +IntExpr2, and current_op(_,_,rdiv) is true.
There is no relation between arithmetic functions and Prolog operators. E.g., ISO sin(Angle) is also not an operator. There is current_arithmetic_function/1 to test whether something is evaluable by is/2, =:=/2, etc. Unfortunately that is not a standard predicate
rdiv is from the days that SWI-Prolog did not have rational numbers as first class citizens. It should not have been an operator, but deleting it will probably make (too) many people unhappy because they still have legacy code from before the days that SWI-Prolog supports rational numbers properly.
I agree. But I would even go a step farther and avoid Prolog operator,
since it still doesn’t unambigiously indicate a non-semantic function.
Sometimes it helps to use the term syntax operator (*) more consistently
in verbal communication and technical documentation than simply using
the ambigious word Prolog operator. This practice is not found in the ISO
core, which uses Prolog operator for both arithmetic function and syntax operator,
depending in which document section the word is used, but this doesn’t
mean it shouldn’t be practiced outside ISO core. There are more examples of
arithmetic functions that are not syntax operators, for example this here:
?- X is xor(1,2).
X = 3.
That SWI-Prolog has also defined it as a syntax operator is not
required as per ISO core since it was only introduced as a
arithmetic function:
(*) Could be my own private vocabulary. What one finds
in the wild is operator notation. But if I want to refer to a
specimen of the concept I prefer saying the syntax operator.
Agree. SWI-Prolog’s section on arithmetic does not talk about operators at all though. It always refers to them as functions (or arithmetic functions).