That was not my proposal If we hide mpfr or LibBF behind an interface that exchanges doubles we could consider having the core of the arithmetic using a array of function pointers. So, ar_sin() (the function implementing Prolog sin/1) does not call libmâs sin(), but instead calls something like funcs[FUNC_SIN]()
. Now we can add some API that allows a foreign library to replace funcs[FUNC_SIN]
. That way we can avoid this whole discussion from affecting the core. The default are the libm functions and we can provide foreign libraries that do things differently. Now we can create mpfr wrappers or plugin crlibm. As anyone can contribute such libraries and distribute them as appropriate, people can choose between license, performance and correctness. I can live with that.
In contrast, adding mpfr, crlibm, LibBF to the core locks us to one of these choices and adds license and/or dependency issues to the core. Iâm not against considering that, but if we go that far Iâd also like to see the other benefits come to SWI-Prolog. This requires more work though as we need change the simple representation of floats as doubles. That might not be too bad as besides the arithmetic, read/write and term ordering, very little of the system is even aware floats exist.
Considering most of the system is agnostic about numbers anyway, it might be possible to define a clean abstract interface that allows anyone to add numeric types, their conversions and their functions.