[m-dev.] for review: remove index preds

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Apr 17 20:26:31 AEST 2000


On 17-Apr-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> Estimated hours taken: 2
> 
> compiler/make_hlds.m:
> 	Do not generate type-specific index predicates for du types which
> 	(a) have user-defined equality, (b) are enums, or (c) have only one
> 	constructor, since for these types the comparison predicate does
> 	not call index.
> 
> compiler/unify_proc.m:
> 	Delete the code for generate bodies for type-specific index predicates
> 	for types which do not need them after the change to make_hlds.m.
> 
> library/builtin.m:
> library/private_builtin.m:
> library/std_util.m:
> 	Delete index predicates that have been made redundant by this change
> 	and the previous change involving index predicates.
> 
> 	This should also fix a problem reported by Fergus, which was caused
> 	by the entry labels of these index predicates were not declared
> 	before being defined. Since they are no longer defined, the problem
> 	should go away.

The log message should start with a short summary.

> +++ compiler/make_hlds.m	2000/04/17 05:56:27
> @@ -2717,14 +2717,26 @@
>  
>  	% The only place that the index predicate for a type can ever
>  	% be called from is the compare predicate for that type.
> -	% However, the compare predicate for an equivalence type
> -	% never calls the index predicate for that type; it calls
> -	% the compare predicate of the expanded type instead.
> -	% We therefore do not generate index predicates for equivalence types.
> +	% The only types whose compare predicates call the type's index
> +	% predicate are du types which

I suggest s/du/discriminated union/

> @@ -2748,11 +2760,14 @@
>  		SpecialPredIds = [unify, compare],
>  		add_special_pred_decl_list(SpecialPredIds, Module0, TVarSet,
>  			Type, TypeId, Body, Context, Status, Module)
> -	;
> -		( Body = eqv_type(_) ->
> -			SpecialPredIds = [unify, compare]
>  		;
> +		(
> +			Body = du_type(Ctors, _, no, no),

It would be clearer to name the third and fourth fields here:

			Body = du_type(Ctors, _, IsEnum, UserDefinedEquality),
			IsEnum = no,
			UserDefinedEquality = no,

> +++ compiler/unify_proc.m	2000/04/14 04:03:27
> @@ -572,6 +572,11 @@
>  		{ error("trying to create unify proc for abstract type") }
>  	).
>  
> +	% This predicate generates the bodies of index predicates for the
> +	% types that need index predicates.
> +	%
> +	% add_special_preds in make_hlds.m should o
> +
>  :- pred unify_proc__generate_index_clauses(hlds_type_body, prog_var, prog_var,

The comment is incomplete.

> diff -u -b -B -r1.46 private_builtin.m
> --- library/private_builtin.m	2000/04/14 07:20:28	1.46
> +++ library/private_builtin.m	2000/04/14 07:22:33
...
> -	% The following two preds are used for index/1 or compare/3
> +	% The following two preds are used for compare/3
>  	% on non-canonical types (types for which there is a
>  	% `where equality is ...' declaration).
> -:- pred builtin_index_non_canonical_type(T::in, int::out) is det.
>  :- pred builtin_compare_non_canonical_type(comparison_result::uo,
>  		T::in, T::in) is det.

s/two preds are/pred is/

Apart from that, this change looks fine.

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