Re: [eclipse-clp-users] compiler leaves spurious choice points

From: Joachim Schimpf <joachim.schimpf_at_monash.edu>
Date: Fri, 21 Jan 2011 10:51:47 +1100
Ulrich Scholz wrote:
> Dear all,
> 
> sometimes, the compiler leaves spurious choice points, i.e., choice points
> that are later discovered to be not there.  I thought (or hoped) that these
> "false" choice points would be eliminated by optimization via type testing.
> 
> Is there any way to prevent this?  It is somewhat distracting during tracing
> and bug fixing.
> 
> Best regards,
> 
> Ulrich
> 
> 
> 
> An example:
> 
> --- ttt.ecl ---
> t2(T1, _T2) :-
>     free(T1),
>     !,
>     writeln(a).
> 
> t2(_T1, T2) :-
>     T2 \== [],
>     writeln(b).
> 
> t2(_T1, []) :-
>     writeln(c).
> ----------------


I would write such an example with a conditional

t2(T1, T2) :-
    ( free(T1) ->
        writeln(a)
    ; T2 == [] ->
        writeln(c)
    ;
        writeln(b)
    ).


An unrelated point: please don't get into the habit of using
free/1 instead of var/1 --- read the explanation at
http://eclipseclp.org/doc/bips/kernel/typetest/free-1.html


-- Joachim
Received on Thu Jan 20 2011 - 23:52:00 CET

This archive was generated by hypermail 2.2.0 : Thu Feb 02 2012 - 02:31:58 CET