[m-dev.] for review: add promise_only_solution/1 to std_util.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Nov 6 12:57:47 AEDT 1998
On 06-Nov-1998, Peter Schachte <pets at cs.mu.OZ.AU> wrote:
> > +:- func promise_only_solution(pred(T)) = T.
> > +:- mode promise_only_solution(pred(out) is cc_multi) = out is det.
> > +:- mode promise_only_solution(pred(out) is cc_nondet) = out is semidet.
>
> To be complete, shouldn't there be versions of promise_only_solution
> for nondet and multi preds as well?
This is a fine suggestion, but for the reasons given
below, I don't think it is worth acting on at this
point in time.
(1)
If you want to use `promise_only_solution' on a nondet or multi
proc, then the work-around is easy -- just use a lambda expression:
promise_only_solution((pred(X::out) is cc_multi :- P(X)))
(2)
Any use of `promise_only_solution' on a nondet or multi proc is
probably a performance bug, because it would be more efficient
to push the pruning inside the definition of that proc.
Therefore, if you do want the pruning to occur outside, it is
arguably better if this is made more visible, so the lambda expression
solution in (1) seems appropriate.
(3)
Adding the extra modes would be quite a pain.
(4)
Even if we did, the set of modes still wouldn't be complete;
e.g. we should add `uo' modes, etc.
(5)
We'll probably replace it with a proper language builtin in
the not too distant future.
> I know the implementation has to
> be completely different, and so this is difficult to do, but it seems
> worth at least documenting this restriction in the current
> implementation.
I think the mode declarations document quite clearly which determinism
it accepts.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list