[m-dev.] for review: function def's for single out det mode library predicates

Fergus Henderson fjh at cs.mu.OZ.AU
Wed May 26 15:49:23 AEST 1999


> --- array.m	1999/03/31 04:42:49	1.53
> +++ array.m	1999/05/26 04:23:58
> @@ -209,6 +215,9 @@
>  :- mode array__bsearch(array_ui, in, pred(in, in, out) is det, out) is det.
>  :- mode array__bsearch(in, in, pred(in, in, out) is det, out) is det.
>  
> +	% XXX rwab1: I observe that the comparison procedure takes mode
> +	% in, in, out whereas historically this type of predicate is
> +

That comment is incomplete, so I will delete it.

> +:- func array__lookup(array(T), int) = T.
> +:- mode array__lookup(array_ui, in) = out is det.
> +
> +	% XXX rwab1: Is the above missing an in, in, in, out mode is det.
> +:- func array__set(array(T), int, T) = array(T).
> +:- mode array__set(array_di, in, in) = array_uo is det.

It's not clear what "the above" refers to here.
Perhaps you meant the predicate version of array__set?
If so, the answer is no, it is not missing an `in, in, in, out' mode --
that mode is deliberately not present, because it can't be implemented
efficiently (O(1)).  There's a separate predicate called `array__slow_set'
which does have that mode.

So I will delete that XXX comment.

> +:- func array__slow_set(array(T), int, T) = array(T).
> +:- mode array__slow_set(array_ui, in, in) = array_uo is det.

The function version of slow_set is missing the `in, in, in, array_uo' mode
which the predicate version has.  Is there any particular reason for that?
I'm assuming there's not, so I will add it.

Apart from those issues, this change looks fine, so I will make the changes
mentioned above and then I will go ahead and commit it.

-- 
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.
--------------------------------------------------------------------------
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