Interestingly a flag strict_iso could solve a few
vexing problems. For example the ISO core standard
did only mention floor/1 with signature F → I.
So in GNU Prolog I can do:
/* GNU Prolog 1.5.0 */
?- current_prolog_flag(strict_iso, X).
X = on
yes
?- X is floor(1).
uncaught exception: error(type_error(float,1),(is)/2)
?- set_prolog_flag(strict_iso, off).
yes
?- X is floor(1).
X = 1
yes
A few Prolog systems don’t share the above behavior,
like SWI-Prolog for example doesn’t throw the type error.
Also SWI-Prolog has nowhere a flag strict_iso.
I think it would be a good idea to agree on a common way to establish ISO strictness. It is a feature that is asked for in the standard and it would make sense if we can find a common way to do it. Ciao and Eclipse (and maybe others) use modules (a package in case of Ciao) such as iso_strict, classic, etc. to allow activating ISO strict compatibility on a per-module basis. A Prolog flag could also work, depending on flag scope (see, e.g., [1]), e.g., in Ciao flags are generally local to modules, but in other systems they are global and this may not be what we want, or at least not in all cases?
[1] D. Cabeza, M.V. Hermenegildo. A New Module System for Prolog. International Conference on Computational Logic, CL2000, LNAI, Num. 1861, pages 131-148, Springer-Verlag, July 2000.
In SWI-Prolog there is already a flag “iso” . Whats the difference
between “iso” and “strict_iso” ? Maybe “iso” and “strict_iso” are just
synonyms. So when I start SWI-Prolog it tells me:
/* SWI-Prolog 9.3.20 */
?- current_prolog_flag(iso, X).
X = false.
Currently I have changed my Prolog system to tell me:
/* Dogelog Player 1.3.1 */
?- current_prolog_flag(strict_iso, X).
X = off.
Because I didn’t find a flag “iso” in GNU Prolog. Only a flag “strict_iso”
is present in GNU Prolog. And I want to be GNU Prolog compatible.
But GNU Prolog defines the effect of “strict_iso” slightly different than
what SWI-Prolog defines for “iso”. GNU Prolog affects current_predicate/1,
floor/1, etc… whereas the SWI-Prolog “iso” flag has different scope.
According to ISO core for example this is the correct behavior:
/* GNU Prolog 1.5.0 */
?- current_predicate((is)/2).
no
As motivated in Is there room to adopt a flag strict_iso? - #2 by jan - General - SWI-Prolog, I’m not interested in this. The SWI-Prolog iso flag is not really usable as it breaks a lot of the libaries. A strict_iso would be even worse. I’m happy to add this flag as a read-only flag that claims false of course
A module-local flag is also a cumbersome solution as it may make calling built-ins in that module iso compliant, but that does not stop affecting the behaviour of libraries. For example, max_member/2 gets the max of a list in the standard order of terms, but SWI-Prolog’s standard order is not ISO compatible. You’d have to make ISO and non-ISO versions of all built-ins affected by this as well as libraries that are affected by this. Well, ISO has no libraries
This all gets hopelessly complicated and solves only a tiny part of the portability puzzle. And believe me, I’ve done quite a bit of porting.
floor/1, etc… consists of a special challenge when one wants to
realize the vision below of a module based ISO standard isolation.
Since it is an evaluable function. You need to have modules that
can provide evaluable functions. This can be extremly challenging
when you have compilers that carry “knowledge” of these functions: