[m-dev.] for review: add `:- pragma type_spec' declarations to the library

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 3 19:54:23 AEDT 2000


On 03-Nov-2000, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> Type specialize predicates in the library. This change
> reduces the time taken by `mmc -C make_hlds' by 3-4%.
> It increases the size of the compiler on murlibobo from
> 9.3M to 9.5M.

> +++ builtin.m	2000/11/02 05:50:55
> @@ -171,10 +171,11 @@
>  	% depending on wheither X is =, <, or > Y in the
>  	% standard ordering.
>  :- pred compare(comparison_result, T, T).
> +	% This mode must be first -- compiler/higher_order.m depends on it.
> +:- mode compare(uo, in, in) is det.

It's unfortunate that this comment needs to go in the interface,
where it will appear in the library reference manual.

To minimize the impact of that problem, I suggest prefixing the
comment with "Note to implementors:" or something like that.

> +++ list.m	2000/10/30 13:26:44
> @@ -15,6 +15,7 @@
>  :- module list.
>  :- interface.
>  :- import_module int.
> +:- import_module term.	% for var/1.
>  
>  %-----------------------------------------------------------------------------%
>  
> @@ -102,6 +103,7 @@
>  	%	in ascending order.  L1 and L2 must be sorted.
>  :- pred list__merge(list(T), list(T), list(T)).
>  :- mode list__merge(in, in, out) is det.
> +:- pragma type_spec(list__merge(in, in, out), T = var(_)).

The `pragma type_spec' declarations are really an
optimization detail that doesn't belong in the main part of
the module interface, IMHO.  I think it would be better to
list them all at the end of the interface section rather
than with each predicate declaration.

Apart from that, this change looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- 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