[m-dev.] Solver type horribleness...

Peter Hawkins hawkinsp at cs.stanford.edu
Fri Mar 3 13:17:26 AEDT 2006


I just thought of this bit of solver type horribleness. Consider this 

:- solver type fd_var.

:- pragma memo(cvar/2).
:- pred cvar(int::in, fd_var::oa) is det.
cvar(_, NewFooVar).  % NewFooVar is created automatically

:- pred constrain_nth_var(int::in) is det.
constrain_nth_var(I) :-
    (if cvar(I, C), C < 5 then true else throw("stop")).

main(!IO) :-
    cvar(1, V),
    impure ask_value(V, Value),
    print(Value, !IO).

The predicate constrain_nth_var doesn't take any solver type arguments, 
takes only input arguments, is pure and deterministic (perhaps the 
if-then-else needs to be changed to disjunction for purity). What stops 
the compiler from optimizing the call away? Perhaps solver type output 
arguments in memoed predicates need to imply impurity?


mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au

More information about the developers mailing list