[m-dev.] for review: --no-special-preds

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 22 16:38:33 AEDT 2000


On 22-Mar-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> Change the way --no-special-preds works, to prepare for the day (soon) when
> unification by RTTI makes it possible to turn on this option and still get
> a working program.
> 
> compiler/make_hlds.m:
...
> 	Also, delete an unused predicate.

> -:- pred add_special_preds(module_info, tvarset, type, type_id, 
> -		hlds_type_body, prog_context, import_status, module_info).
> -:- mode add_special_preds(in, in, in, in, in, in, in, out) is det.
> -
> -add_special_preds(Module0, TVarSet, Type, TypeId,
> -			Body, Context, Status, Module) :-
> -	special_pred_list(SpecialPredIds),
> -	( Body = abstract_type ->
> -		add_special_pred_decl_list(SpecialPredIds, Module0, TVarSet,
> -				Type, TypeId, Context, Status, Module)
> -	;
> -		add_special_pred_list(SpecialPredIds, Module0, TVarSet, Type,
> -				TypeId, Body, Context, Status, Module)
> -	).
> -	

The code for this predicate is very similar to the code
that occurs in-line in module_add_type_defn in make_hlds.m:

		(
			( 
				{ Body = abstract_type }
			;
				{ Body = uu_type(_) }
			;
				{ type_id_has_hand_defined_rtti(TypeId) }
			)
		->
			{ special_pred_list(SpecialPredIds) },
			{ add_special_pred_decl_list(SpecialPredIds,
					Module2, TVarSet, Type, TypeId,
					Context, Status, Module3) }
		;
			{ special_pred_list(SpecialPredIds) },
			{ add_special_pred_list(SpecialPredIds,
					Module2, TVarSet, Type, TypeId,
					Body, Context, Status, Module3) }
		),

Indeed, it is pretty much identical, except that the condition of
the if-then-else is slightly different.

The predicate add_special_preds that you're deleting does provide a useful (if minor)
abstraction, so rather than deleting it, I suggest you replace the code
above with a call to add_special_preds, and of course modify the condition of
the if-then-else in add_special_preds to match the condition in the code
above, which is the correct one.

Otherwise, this change looks fine.  Thanks.

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