[m-rev.] for review: instmap_delta_restrict

Peter Wang novalazy at gmail.com
Fri Apr 1 19:44:23 AEDT 2022


On Fri, 01 Apr 2022 17:21:51 +1100 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> For review by anyone. I am mostly seeking feedback on
> the names of the new library predicates, and whether they
> should be in the documented part of the interface or not.
> If yes, I intend to add an entry to NEWS with the final name.

> diff --git a/library/map.m b/library/map.m
> index e88f21717..5278bd150 100644
> --- a/library/map.m
> +++ b/library/map.m
> @@ -313,6 +313,14 @@
>  
>  :- pred keys_and_values(map(K, V)::in, list(K)::out, list(V)::out) is det.
>  
> +    % Given a map, succeed if and only if the given list is the list
> +    % of all the keys in the map.
> +    % `keys_match(Map, List)' is equivalent to the conjunction,
> +    % `keys(Map, Keys), Keys = List", but it allocates no memory,
> +    % and it traverses Map only up to the first mismatch.
> +    %
> +:- pred keys_match(map(K, V)::in, list(K)::in) is semidet.
> +

Since it requires the keys in the list are in sorted order to succeed,
I suggest naming the predicate sorted_keys_match, and using sorted_keys
in the comment.

Or make sorted_keys/2 multi-modal.

Peter


More information about the reviews mailing list