[m-rev.] for review: move same_type and find_functor to interface

Julien Fischer juliensf at csse.unimelb.edu.au
Mon Sep 24 17:15:35 AEST 2007


On Mon, 24 Sep 2007, Ondrej Bojar wrote:

> Estimated hours taken: 0
> Branch: main
>
> library/term.m:
>    Move same_type/2 and find_functor/5 to interface. Both are useful in 
> custom
>    pickling and unpickling predicates.

Announce this in the NEWS file.

> Index: library/term.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/library/term.m,v
> retrieving revision 1.127
> diff -u -r1.127 term.m
> --- library/term.m	13 Feb 2007 01:58:54 -0000	1.127
> +++ library/term.m	24 Sep 2007 06:25:46 -0000
> @@ -128,6 +128,16 @@
> :- func univ_to_term(univ) = term(_).
> :- pred univ_to_term(univ::in, term(_)::out) is det.
>
> +    % Given a type descriptor, a functor name and arity, finds the functor
> +    % index and the types of its arguments.
> +    %

You should also document the conditions under which this fails.

What do you mean by functor index?  The RTTI pred in construct and
deconstruct use both functor_number_lex and functor_number_ordinal.
Which is meant here?

> +:- pred find_functor(type_desc::in, string::in, int::in,
> +    int::out, list(type_desc.type_desc)::out) is semidet.

There is no point module qualifying type_desc there.

> +    % Ensures type identity of the two arguments.
> +    %
> +:- pred same_type(T::unused, T::unused) is det.

I think `term' is the wrong module to be exporting these from; neither
of these predicates has anything to do with the term/1 type.

I would suggest putting find_functor/5 in the construct module (it is
similar to construct.get_functor) and putting same_type/2 in `type_desc'.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list