Re: [eclipse-clp-users] Evaluation of arithmetic expressions

From: Kish Shen <kisshen_at_...5...>
Date: Fri, 10 Jul 2009 18:04:11 +0100
Hi Takis,

Sorry for the delay in responding to your query...

Takis Stamatopoulos wrote:
> Hello everybody,
> 
> I wonder whether the following behaviour of Eclipse is compliant with
> the standard:
> 
> [eclipse 1]: X = 1+2, Y is X+5.
> number expected in +(1 + 2, 5, Y)
> Abort
>
> It is explicitly mentioned in paragraph 8.3.4. of the User Manual that
> the query should be
> 
> [eclipse 2]: X = 1+2, Y is eval(X)+5.
> 
> X = 1 + 2
> Y = 8
> 
> but is this what should be done according to the standard?
> 
>      Best Regards,
> 
>         Takis
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users

The need for eval/1 is not compliant with the ISO standard. We have 
never tried to make ECLiPSe completely compatible with the ISO standard,
and we provide the iso library to provide better compatibility with ISO.
At the moment, the ISO library does not support the implicit evaluation 
of expressions constructed at run-time; this is an oversight, and we 
will correct this.

Some of the reason for eval wrapper is discussed in the user manual 
section 8.3.4 you mentioned -- it allows arithmetic expressions to be 
compiled efficiently. eval tells ECLiPSe to parse the expression at 
runtime.

To reproduce the ISO behaviour, the `number expected' error handler can 
be redefined to call eval at run-time, but this is less efficient than 
requiring eval at compile time around variables which may become 
expressions.

Cheers,

Kish

-- 
This e-mail may contain confidential and privileged material for the
sole use of the intended recipient. Any review, use, distribution or
disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact
the sender by reply e-mail and delete all copies of this message.
Cisco Systems Limited (Company Number: 02558939), is registered in
England and Wales with its registered office at 1 Callaghan Square,
Cardiff, South Glamorgan CF10 5BT.
Received on Fri Jul 10 2009 - 17:04:18 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 25 2024 - 15:13:20 CEST