Re: [eclipse-clp-users] Standard compliance

From: Joachim Schimpf <jschimpf_at_...311...>
Date: Thu, 10 Mar 2016 16:24:18 +0000
On 10/03/16 11:47, Panagiotis Stamatopoulos wrote:
> Hello everybody,
>
> Just a simple question, mainly to the ECLiPSe developers:
> Does the following behavior comply with the standard?
>
> [eclipse 1]: X = 5+3, Y is X+7.
> number expected in +(5 + 3, 7, _360)
> Abort
>
> Other Prolog systems accept the query and instantiate Y to 15.

You are right, the default behaviour of ECLiPSe differs here
from the ISO-Prolog standard.  The clean way to write this in
ECLiPSe is

[eclipse 1]: X = 5+3, Y is eval(X)+7.
X = 5 + 3
Y = 15
Yes (0.00s cpu)


There are good reasons for the ECLiPSe behaviour, both from a typing
standpoint (is X a numeric variable or a symbolic expression
variable?), and for enabling compile-time optimizations.

There are other Prolog implementers who agree that the standard should
have been less permissive here, and therefore you find the eval/1
feature also in other systems, e.g. SWI-Prolog
(http://www.swi-prolog.org/pldoc/doc_for?object=f%28eval/1%29)


However, if needed, you can get full standard-conforming behaviour by
using ECLiPSe's iso or iso_strict library, either via a command line
option, or any other of the methods described in
http://eclipseclp.org/doc/bips/lib/iso/index.html

coninferpc$ eclipse -L iso
...
[eclipse 1]: X = 5+3, Y is X+7.
X = 5 + 3
Y = 15
Yes (0.00s cpu)

But note that the eval/1 formulation will be more efficient.


Cheers,
Joachim
Received on Thu Mar 10 2016 - 16:24:27 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST