[m-rev.] diff: more cleanups

Zoltan Somogyi zs at cs.mu.OZ.AU
Wed Mar 31 18:49:33 AEST 2004


compiler/det_util.m:
compiler/hlds_goal.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/prog_data.m:
	Bring these compiler modules up to our current coding standards.
	Use predmode declarations and state variable syntax where relevant.
	Reorder arguments where this is needed for the use state variables.
	Make the order of predicate definitions correspond to the order of
	their declarations.

compiler/unique_modes.m:
	Conform to a changed argument order.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/det_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/det_util.m,v
retrieving revision 1.25
diff -u -b -r1.25 det_util.m
--- compiler/det_util.m	15 Mar 2003 03:08:44 -0000	1.25
+++ compiler/det_util.m	29 Mar 2004 04:43:42 -0000
@@ -33,8 +33,7 @@
 	% Given a goal and an initial instmap, compute the final instmap that
 	% results from the initial instmap after execution of the goal.
 
-:- pred update_instmap(hlds_goal, instmap, instmap).
-:- mode update_instmap(in, in, out) is det.
+:- pred update_instmap(hlds_goal::in, instmap::in, instmap::out) is det.
 
 	% Given a list of cases, and a list of the possible cons_ids
 	% that the switch variable could be bound to, select out only
@@ -42,61 +41,43 @@
 	% We assume that the list of cases and the list of cons_ids
 	% are sorted, so that we can do this using a simple sorted merge.
 
-:- pred delete_unreachable_cases(list(case), list(cons_id),
-	list(case)).
-:- mode delete_unreachable_cases(in, in, out) is det.
+:- pred delete_unreachable_cases(list(case)::in, list(cons_id)::in,
+	list(case)::out) is det.
 
 	% Update the current substitution to account for the effects
 	% of the given unification.
 
-:- pred interpret_unify(prog_var, unify_rhs, prog_substitution,
-		prog_substitution).
-:- mode interpret_unify(in, in, in, out) is semidet.
+:- pred interpret_unify(prog_var::in, unify_rhs::in,
+	prog_substitution::in, prog_substitution::out) is semidet.
 
 	% Look up the determinism of a procedure.
 
-:- pred det_lookup_detism(det_info, pred_id, proc_id, determinism).
-:- mode det_lookup_detism(in, in, in, out) is det.
+:- pred det_lookup_detism(det_info::in, pred_id::in, proc_id::in,
+	determinism::out) is det.
 
-:- pred det_get_proc_info(det_info, proc_info).
-:- mode det_get_proc_info(in, out) is det.
+:- pred det_get_proc_info(det_info::in, proc_info::out) is det.
 
-:- pred det_lookup_var_type(module_info, proc_info, prog_var, hlds_type_defn).
-:- mode det_lookup_var_type(in, in, in, out) is semidet.
+:- pred det_lookup_var_type(module_info::in, proc_info::in, prog_var::in,
+	hlds_type_defn::out) is semidet.
 
-:- pred det_no_output_vars(set(prog_var), instmap, instmap_delta, det_info).
-:- mode det_no_output_vars(in, in, in, in) is semidet.
-
-:- pred det_info_init(module_info, vartypes, pred_id, proc_id, globals,
-		det_info).
-:- mode det_info_init(in, in, in, in, in, out) is det.
-
-:- pred det_info_get_module_info(det_info, module_info).
-:- mode det_info_get_module_info(in, out) is det.
-
-:- pred det_info_get_pred_id(det_info, pred_id).
-:- mode det_info_get_pred_id(in, out) is det.
-
-:- pred det_info_get_proc_id(det_info, proc_id).
-:- mode det_info_get_proc_id(in, out) is det.
-
-:- pred det_info_get_reorder_conj(det_info, bool).
-:- mode det_info_get_reorder_conj(in, out) is det.
-
-:- pred det_info_get_reorder_disj(det_info, bool).
-:- mode det_info_get_reorder_disj(in, out) is det.
-
-:- pred det_info_get_fully_strict(det_info, bool).
-:- mode det_info_get_fully_strict(in, out) is det.
-
-:- pred det_info_set_module_info(det_info, module_info, det_info).
-:- mode det_info_set_module_info(in, in, out) is det.
-
-:- pred det_info_get_vartypes(det_info, vartypes).
-:- mode det_info_get_vartypes(in, out) is det.
-
-:- pred det_info_set_vartypes(det_info, vartypes, det_info).
-:- mode det_info_set_vartypes(in, in, out) is det.
+:- pred det_no_output_vars(set(prog_var)::in, instmap::in, instmap_delta::in,
+	det_info::in) is semidet.
+
+:- pred det_info_init(module_info::in, vartypes::in, pred_id::in, proc_id::in,
+	globals::in, det_info::out) is det.
+
+:- pred det_info_get_module_info(det_info::in, module_info::out) is det.
+:- pred det_info_get_pred_id(det_info::in, pred_id::out) is det.
+:- pred det_info_get_proc_id(det_info::in, proc_id::out) is det.
+:- pred det_info_get_reorder_conj(det_info::in, bool::out) is det.
+:- pred det_info_get_reorder_disj(det_info::in, bool::out) is det.
+:- pred det_info_get_fully_strict(det_info::in, bool::out) is det.
+:- pred det_info_get_vartypes(det_info::in, vartypes::out) is det.
+
+:- pred det_info_set_module_info(det_info::in, module_info::in, det_info::out)
+	is det.
+:- pred det_info_set_vartypes(det_info::in, vartypes::in, det_info::out)
+	is det.
 
 %-----------------------------------------------------------------------------%
 
@@ -109,9 +90,9 @@
 
 :- import_module map, term, require, std_util.
 
-update_instmap(_Goal0 - GoalInfo0, InstMap0, InstMap) :-
+update_instmap(_Goal0 - GoalInfo0, !InstMap) :-
 	goal_info_get_instmap_delta(GoalInfo0, DeltaInstMap),
-	instmap__apply_instmap_delta(InstMap0, DeltaInstMap, InstMap).
+	instmap__apply_instmap_delta(!.InstMap, DeltaInstMap, !:InstMap).
 
 delete_unreachable_cases([], _, []).
 delete_unreachable_cases([_ | _], [], []).
@@ -126,19 +107,16 @@
 		delete_unreachable_cases([Case | Cases0], ConsIds, Cases)
 	).
 
-interpret_unify(X, var(Y), Subst0, Subst) :-
-	term__unify(term__variable(X), term__variable(Y),
-		Subst0, Subst).
-interpret_unify(X, functor(ConsId, _, ArgVars), Subst0, Subst) :-
+interpret_unify(X, var(Y), !Subst) :-
+	term__unify(term__variable(X), term__variable(Y), !Subst).
+interpret_unify(X, functor(ConsId, _, ArgVars), !Subst) :-
 	term__var_list_to_term_list(ArgVars, ArgTerms),
 	cons_id_and_args_to_term(ConsId, ArgTerms, RhsTerm),
-	term__unify(term__variable(X), RhsTerm, Subst0, Subst).
-interpret_unify(_X, lambda_goal(_Purity, _POrF, _Method, _Fix, _NonLocals,
-			_Vars, _Modes, _Det, _Goal), Subst0, Subst) :-
+	term__unify(term__variable(X), RhsTerm, !Subst).
+interpret_unify(_X, lambda_goal(_, _, _, _, _, _, _, _, _), !Subst).
 		% For ease of implementation we just ignore unifications with
 		% lambda terms.  This is a safe approximation, it just
 		% prevents us from optimizing them as well as we would like.
-	Subst = Subst0.
 
 det_lookup_detism(DetInfo, PredId, ModeId, Detism) :-
 	det_info_get_module_info(DetInfo, ModuleInfo),
@@ -169,13 +147,13 @@
 
 det_no_output_vars(Vars, InstMap, InstMapDelta, DetInfo) :-
 	det_info_get_module_info(DetInfo, ModuleInfo),
-	instmap__no_output_vars(InstMap, InstMapDelta, Vars, DetInfo^vartypes,
-		ModuleInfo).
+	instmap__no_output_vars(InstMap, InstMapDelta, Vars,
+		DetInfo ^ vartypes, ModuleInfo).
 
 %-----------------------------------------------------------------------------%
 
-:- type det_info	
-	--->	det_info(
+:- type det_info --->
+	det_info(
 		module_info :: module_info,
 		vartypes :: vartypes,
 		pred_id :: pred_id,	% the id of the proc
@@ -192,15 +170,13 @@
 	DetInfo = det_info(ModuleInfo, VarTypes, PredId, ProcId,
 		ReorderConj, ReorderDisj, FullyStrict).
 
-det_info_get_module_info(DetInfo, DetInfo^module_info).
-det_info_get_pred_id(DetInfo, DetInfo^pred_id).
-det_info_get_proc_id(DetInfo, DetInfo^proc_id).
-det_info_get_reorder_conj(DetInfo, DetInfo^reorder_conj).
-det_info_get_reorder_disj(DetInfo, DetInfo^reorder_disj).
-det_info_get_fully_strict(DetInfo, DetInfo^fully_strict).
-det_info_get_vartypes(DetInfo, DetInfo^vartypes).
-
-det_info_set_module_info(DetInfo, ModuleInfo,
-		DetInfo^module_info := ModuleInfo).
-det_info_set_vartypes(DetInfo, VarTypes,
-		DetInfo^vartypes := VarTypes).
+det_info_get_module_info(DI, DI ^ module_info).
+det_info_get_pred_id(DI, DI ^ pred_id).
+det_info_get_proc_id(DI, DI ^ proc_id).
+det_info_get_reorder_conj(DI, DI ^ reorder_conj).
+det_info_get_reorder_disj(DI, DI ^ reorder_disj).
+det_info_get_fully_strict(DI, DI ^ fully_strict).
+det_info_get_vartypes(DI, DI ^ vartypes).
+
+det_info_set_module_info(DI, ModuleInfo, DI ^ module_info := ModuleInfo).
+det_info_set_vartypes(DI, VarTypes, DI ^ vartypes := VarTypes).
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.112
diff -u -b -r1.112 hlds_goal.m
--- compiler/hlds_goal.m	20 Feb 2004 01:58:50 -0000	1.112
+++ compiler/hlds_goal.m	28 Mar 2004 16:26:13 -0000
@@ -19,7 +19,7 @@
 :- import_module parse_tree__inst.
 :- import_module parse_tree__prog_data.
 
-:- import_module bool, char, list, set, map, std_util.
+:- import_module bool, char, list, set, std_util.
 
 %-----------------------------------------------------------------------------%
 
@@ -238,12 +238,10 @@
 	;	aditi_builtin(
 			aditi_builtin,
 			simple_call_id
-		)
-	.
+		).
 
 	% Get a description of a generic_call goal.
-:- pred hlds_goal__generic_call_id(generic_call, call_id).
-:- mode hlds_goal__generic_call_id(in, out) is det.
+:- pred hlds_goal__generic_call_id(generic_call::in, call_id::out) is det.
 
 	% Determine whether a generic_call is calling
 	% a predicate or a function
@@ -283,7 +281,8 @@
 	% builtins of the second sort, although we used to handle call/N
 	% that way.
 
-:- type builtin_state	--->	inline_builtin
+:- type builtin_state
+	--->	inline_builtin
 			;	out_of_line_builtin
 			;	not_builtin.
 
@@ -292,9 +291,11 @@
 % Information for switches
 %
 
-:- type case		--->	case(cons_id, hlds_goal).
-			%	functor to match with,
-			%	goal to execute if match succeeds.
+:- type case
+	--->	case(
+			cons_id,	% functor to match with,
+			hlds_goal 	% goal to execute if match succeeds.
+		).
 
 %-----------------------------------------------------------------------------%
 %
@@ -571,8 +572,7 @@
 		)
 	;	construct_dynamically		% Allocate a new term on the
 						% heap
-	;	reuse_cell(cell_to_reuse)	% Reuse an existing heap cell
-	.
+	;	reuse_cell(cell_to_reuse).	% Reuse an existing heap cell
 
 	% Information on how to construct an argument for
 	% a static construction unification.  Each such
@@ -605,8 +605,7 @@
 	% `cell_is_unique' is always a safe approximation.
 :- type cell_is_unique
 	--->	cell_is_unique
-	;	cell_is_shared
-	.
+	;	cell_is_shared.
 
 :- type unify_mode	==	pair(mode, mode).
 
@@ -630,16 +629,10 @@
 :- type hlds_goal_info.
 :- type hlds_goal_code_gen_info.
 
-:- pred goal_info_init(hlds_goal_info).
-:- mode goal_info_init(out) is det.
-
-:- pred goal_info_init(prog_context, hlds_goal_info).
-:- mode goal_info_init(in, out) is det.
-
-:- pred goal_info_init(set(prog_var), instmap_delta, determinism, purity,
-		hlds_goal_info).
-:- mode goal_info_init(in, in, in, in, out) is det.
-
+:- pred goal_info_init(hlds_goal_info::out) is det.
+:- pred goal_info_init(prog_context::in, hlds_goal_info::out) is det.
+:- pred goal_info_init(set(prog_var)::in, instmap_delta::in, determinism::in,
+	purity::in, hlds_goal_info::out) is det.
 :- pred goal_info_init(set(prog_var)::in, instmap_delta::in, determinism::in,
 	purity::in, prog_context::in, hlds_goal_info::out) is det.
 
@@ -652,97 +645,63 @@
 % or in both the pre-death and pre-birth sets.
 
 	% see also goal_info_get_code_model in code_model.m
-:- pred goal_info_get_determinism(hlds_goal_info, determinism).
-:- mode goal_info_get_determinism(in, out) is det.
-
-:- pred goal_info_set_determinism(hlds_goal_info, determinism,
-	hlds_goal_info).
-:- mode goal_info_set_determinism(in, in, out) is det.
-
-:- pred goal_info_get_nonlocals(hlds_goal_info, set(prog_var)).
-:- mode goal_info_get_nonlocals(in, out) is det.
-
-:- pred goal_info_get_code_gen_nonlocals(hlds_goal_info, set(prog_var)).
-:- mode goal_info_get_code_gen_nonlocals(in, out) is det.
-
-:- pred goal_info_set_nonlocals(hlds_goal_info, set(prog_var), hlds_goal_info).
-:- mode goal_info_set_nonlocals(in, in, out) is det.
-
-:- pred goal_info_set_code_gen_nonlocals(hlds_goal_info,
-		set(prog_var), hlds_goal_info).
-:- mode goal_info_set_code_gen_nonlocals(in, in, out) is det.
-
-:- pred goal_info_get_features(hlds_goal_info, set(goal_feature)).
-:- mode goal_info_get_features(in, out) is det.
-
-:- pred goal_info_set_features(hlds_goal_info, set(goal_feature),
-					hlds_goal_info).
-:- mode goal_info_set_features(in, in, out) is det.
-
-:- pred goal_info_add_feature(hlds_goal_info, goal_feature, hlds_goal_info).
-:- mode goal_info_add_feature(in, in, out) is det.
-
-:- pred goal_info_remove_feature(hlds_goal_info, goal_feature,
-					hlds_goal_info).
-:- mode goal_info_remove_feature(in, in, out) is det.
-
-:- pred goal_info_has_feature(hlds_goal_info, goal_feature).
-:- mode goal_info_has_feature(in, in) is semidet.
-
-:- pred goal_info_get_instmap_delta(hlds_goal_info, instmap_delta).
-:- mode goal_info_get_instmap_delta(in, out) is det.
-
-:- pred goal_info_set_instmap_delta(hlds_goal_info, instmap_delta,
-				hlds_goal_info).
-:- mode goal_info_set_instmap_delta(in, in, out) is det.
-
-:- pred goal_info_get_context(hlds_goal_info, prog_context).
-:- mode goal_info_get_context(in, out) is det.
-
-:- pred goal_info_set_context(hlds_goal_info, prog_context, hlds_goal_info).
-:- mode goal_info_set_context(in, in, out) is det.
-
-:- pred goal_info_get_goal_path(hlds_goal_info, goal_path).
-:- mode goal_info_get_goal_path(in, out) is det.
-
-:- pred goal_info_set_goal_path(hlds_goal_info, goal_path, hlds_goal_info).
-:- mode goal_info_set_goal_path(in, in, out) is det.
-
-:- pred goal_info_get_code_gen_info(hlds_goal_info, hlds_goal_code_gen_info).
-:- mode goal_info_get_code_gen_info(in, out) is det.
-
-:- pred goal_info_set_code_gen_info(hlds_goal_info, hlds_goal_code_gen_info,
-	hlds_goal_info).
-:- mode goal_info_set_code_gen_info(in, in, out) is det.
-
-:- pred goal_get_nonlocals(hlds_goal, set(prog_var)).
-:- mode goal_get_nonlocals(in, out) is det.
+:- pred goal_info_get_determinism(hlds_goal_info::in, determinism::out) is det.
+:- pred goal_info_get_instmap_delta(hlds_goal_info::in, instmap_delta::out)
+	is det.
+:- pred goal_info_get_context(hlds_goal_info::in, prog_context::out) is det.
+:- pred goal_info_get_nonlocals(hlds_goal_info::in, set(prog_var)::out) is det.
+:- pred goal_info_get_code_gen_nonlocals(hlds_goal_info::in,
+	set(prog_var)::out) is det.
+:- pred goal_info_get_features(hlds_goal_info::in, set(goal_feature)::out)
+	is det.
+:- pred goal_info_get_goal_path(hlds_goal_info::in, goal_path::out) is det.
+:- pred goal_info_get_code_gen_info(hlds_goal_info::in,
+	hlds_goal_code_gen_info::out) is det.
+
+:- pred goal_info_set_determinism(hlds_goal_info::in, determinism::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_instmap_delta(hlds_goal_info::in, instmap_delta::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_context(hlds_goal_info::in, prog_context::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_nonlocals(hlds_goal_info::in, set(prog_var)::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_code_gen_nonlocals(hlds_goal_info::in, set(prog_var)::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_features(hlds_goal_info::in, set(goal_feature)::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_goal_path(hlds_goal_info::in, goal_path::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_set_code_gen_info(hlds_goal_info::in,
+	hlds_goal_code_gen_info::in, hlds_goal_info::out) is det.
+
+:- pred goal_get_nonlocals(hlds_goal::in, set(prog_var)::out) is det.
+
+:- pred goal_info_add_feature(hlds_goal_info::in, goal_feature::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_remove_feature(hlds_goal_info::in, goal_feature::in,
+	hlds_goal_info::out) is det.
+:- pred goal_info_has_feature(hlds_goal_info::in, goal_feature::in) is semidet.
 
-:- pred goal_add_feature(hlds_goal, goal_feature, hlds_goal).
-:- mode goal_add_feature(in, in, out) is det.
+:- pred goal_add_feature(hlds_goal::in, goal_feature::in, hlds_goal::out)
+	is det.
+:- pred goal_remove_feature(hlds_goal::in, goal_feature::in, hlds_goal::out)
+	is det.
+:- pred goal_has_feature(hlds_goal::in, goal_feature::in) is semidet.
 
-:- pred goal_remove_feature(hlds_goal, goal_feature, hlds_goal).
-:- mode goal_remove_feature(in, in, out) is det.
+%  Update a goal info to reflect the specified purity
+:- pred add_goal_info_purity_feature(hlds_goal_info::in, purity::in,
+	hlds_goal_info::out) is det.
 
-:- pred goal_has_feature(hlds_goal, goal_feature).
-:- mode goal_has_feature(in, in) is semidet.
+	% Determine the purity of a goal from its hlds_goal_info.
+:- pred infer_goal_info_purity(hlds_goal_info::in, purity::out) is det.
 
-%  Update a goal info to reflect the specified purity
-:- pred add_goal_info_purity_feature(hlds_goal_info, purity, hlds_goal_info).
-:- mode add_goal_info_purity_feature(in, in, out) is det.
+	% Check if a hlds_goal_info is for a pure goal.
+:- pred goal_info_is_pure(hlds_goal_info::in) is semidet.
 
-%  Determine the purity of a goal from its hlds_goal_info.
-:- pred infer_goal_info_purity(hlds_goal_info, purity).
-:- mode infer_goal_info_purity(in, out) is det.
-
-%  Check if a hlds_goal_info is for a pure goal
-:- pred goal_info_is_pure(hlds_goal_info).
-:- mode goal_info_is_pure(in) is semidet.
-
-%  Check if a hlds_goal_info is for an impure goal.  Fails if the goal is
-%  semipure, so this isn't the same as \+ goal_info_is_pure.
-:- pred goal_info_is_impure(hlds_goal_info).
-:- mode goal_info_is_impure(in) is semidet.
+	% Check if a hlds_goal_info is for an impure goal. Fails if the goal
+	% is semipure, so this isn't the same as \+ goal_info_is_pure.
+:- pred goal_info_is_impure(hlds_goal_info::in) is semidet.
 
 :- type goal_feature
 	--->	constraint	% This is included if the goal is
@@ -832,121 +791,105 @@
 	% If the goal is a conjunction, then return its conjuncts,
 	% otherwise return the goal as a singleton list.
 
-:- pred goal_to_conj_list(hlds_goal, list(hlds_goal)).
-:- mode goal_to_conj_list(in, out) is det.
+:- pred goal_to_conj_list(hlds_goal::in, list(hlds_goal)::out) is det.
 
 	% Convert a goal to a list of parallel conjuncts.
 	% If the goal is a parallel conjunction, then return its conjuncts,
 	% otherwise return the goal as a singleton list.
 
-:- pred goal_to_par_conj_list(hlds_goal, list(hlds_goal)).
-:- mode goal_to_par_conj_list(in, out) is det.
+:- pred goal_to_par_conj_list(hlds_goal::in, list(hlds_goal)::out) is det.
 
 	% Convert a goal to a list of disjuncts.
 	% If the goal is a disjunction, then return its disjuncts,
 	% otherwise return the goal as a singleton list.
 
-:- pred goal_to_disj_list(hlds_goal, list(hlds_goal)).
-:- mode goal_to_disj_list(in, out) is det.
+:- pred goal_to_disj_list(hlds_goal::in, list(hlds_goal)::out) is det.
 
 	% Convert a list of conjuncts to a goal.
 	% If the list contains only one goal, then return that goal,
 	% otherwise return the conjunction of the conjuncts,
 	% with the specified goal_info.
 
-:- pred conj_list_to_goal(list(hlds_goal), hlds_goal_info, hlds_goal).
-:- mode conj_list_to_goal(in, in, out) is det.
+:- pred conj_list_to_goal(list(hlds_goal)::in, hlds_goal_info::in,
+	hlds_goal::out) is det.
 
 	% Convert a list of parallel conjuncts to a goal.
 	% If the list contains only one goal, then return that goal,
 	% otherwise return the parallel conjunction of the conjuncts,
 	% with the specified goal_info.
 
-:- pred par_conj_list_to_goal(list(hlds_goal), hlds_goal_info, hlds_goal).
-:- mode par_conj_list_to_goal(in, in, out) is det.
+:- pred par_conj_list_to_goal(list(hlds_goal)::in, hlds_goal_info::in,
+	hlds_goal::out) is det.
 
 	% Convert a list of disjuncts to a goal.
 	% If the list contains only one goal, then return that goal,
 	% otherwise return the disjunction of the disjuncts,
 	% with the specified goal_info.
 
-:- pred disj_list_to_goal(list(hlds_goal), hlds_goal_info, hlds_goal).
-:- mode disj_list_to_goal(in, in, out) is det.
+:- pred disj_list_to_goal(list(hlds_goal)::in, hlds_goal_info::in,
+	hlds_goal::out) is det.
 
 	% Takes a goal and a list of goals, and conjoins them
 	% (with a potentially blank goal_info).
 
-:- pred conjoin_goal_and_goal_list(hlds_goal, list(hlds_goal),
-	hlds_goal).
-:- mode conjoin_goal_and_goal_list(in, in, out) is det.
+:- pred conjoin_goal_and_goal_list(hlds_goal::in, list(hlds_goal)::in,
+	hlds_goal::out) is det.
 
 	% Conjoin two goals (with a potentially blank goal_info).
 
-:- pred conjoin_goals(hlds_goal, hlds_goal, hlds_goal).
-:- mode conjoin_goals(in, in, out) is det.
+:- pred conjoin_goals(hlds_goal::in, hlds_goal::in, hlds_goal::out) is det.
 
 	% Negate a goal, eliminating double negations as we go.
 	%
-:- pred negate_goal(hlds_goal, hlds_goal_info, hlds_goal).
-:- mode negate_goal(in, in, out) is det.
+:- pred negate_goal(hlds_goal::in, hlds_goal_info::in, hlds_goal::out) is det.
 
 	% Return yes if goal(s) contain any foreign code
 :- func goal_has_foreign(hlds_goal) = bool.
-:- mode goal_has_foreign(in) = out is det.
 :- func goal_list_has_foreign(list(hlds_goal)) = bool.
-:- mode goal_list_has_foreign(in) = out is det.
 
 	% A goal is atomic iff it doesn't contain any sub-goals
 	% (except possibly goals inside lambda expressions --
 	% but lambda expressions will get transformed into separate
 	% predicates by the polymorphism.m pass).
 
-:- pred goal_is_atomic(hlds_goal_expr).
-:- mode goal_is_atomic(in) is semidet.
+:- pred goal_is_atomic(hlds_goal_expr::in) is semidet.
 
 	% Return the HLDS equivalent of `true'.
-:- pred true_goal(hlds_goal).
-:- mode true_goal(out) is det.
+:- pred true_goal(hlds_goal::out) is det.
 
-:- pred true_goal(prog_context, hlds_goal).
-:- mode true_goal(in, out) is det.
+:- pred true_goal(prog_context::in, hlds_goal::out) is det.
 
 	% Return the HLDS equivalent of `fail'.
-:- pred fail_goal(hlds_goal).
-:- mode fail_goal(out) is det.
+:- pred fail_goal(hlds_goal::out) is det.
 
-:- pred fail_goal(prog_context, hlds_goal).
-:- mode fail_goal(in, out) is det.
+:- pred fail_goal(prog_context::in, hlds_goal::out) is det.
 
        % Return the union of all the nonlocals of a list of goals.
-:- pred goal_list_nonlocals(list(hlds_goal), set(prog_var)).
-:- mode goal_list_nonlocals(in, out) is det.
+:- pred goal_list_nonlocals(list(hlds_goal)::in, set(prog_var)::out) is det.
 
        % Compute the instmap_delta resulting from applying
        % all the instmap_deltas of the given goals.
-:- pred goal_list_instmap_delta(list(hlds_goal), instmap_delta).
-:- mode goal_list_instmap_delta(in, out) is det.
+:- pred goal_list_instmap_delta(list(hlds_goal)::in, instmap_delta::out)
+	is det.
 
        % Compute the determinism of a list of goals.
-:- pred goal_list_determinism(list(hlds_goal), determinism).
-:- mode goal_list_determinism(in, out) is det.
+:- pred goal_list_determinism(list(hlds_goal)::in, determinism::out) is det.
 
 	% Compute the purity of a list of goals. 
-:- pred goal_list_purity(list(hlds_goal), purity).
-:- mode goal_list_purity(in, out) is det.
+:- pred goal_list_purity(list(hlds_goal)::in, purity::out) is det.
 
 	% Change the contexts of the goal_infos of all the sub-goals
 	% of the given goal. This is used to ensure that error messages
 	% for automatically generated unification procedures have a useful
 	% context.
-:- pred set_goal_contexts(prog_context, hlds_goal, hlds_goal).
-:- mode set_goal_contexts(in, in, out) is det.
+:- pred set_goal_contexts(prog_context::in, hlds_goal::in, hlds_goal::out)
+	is det.
 
 	% Create the hlds_goal for a unification, filling in all the as yet
 	% unknown slots with dummy values.
-:- pred create_atomic_unification(prog_var, unify_rhs, prog_context,
-			unify_main_context, unify_sub_contexts, hlds_goal).
-:- mode create_atomic_unification(in, in, in, in, in, out) is det.
+:- pred create_atomic_unification(prog_var::in, unify_rhs::in,
+	prog_context::in, unify_main_context::in, unify_sub_contexts::in,
+	hlds_goal::out) is det.
 
 	%
 	% Produce a goal to construct a given constant.
@@ -956,72 +899,48 @@
 	% only if the variable being assigned to has no aliases.
 	%
 
-:- pred make_int_const_construction(prog_var, int, hlds_goal).
-:- mode make_int_const_construction(in, in, out) is det.
-
-:- pred make_string_const_construction(prog_var, string, hlds_goal).
-:- mode make_string_const_construction(in, in, out) is det.
-
-:- pred make_float_const_construction(prog_var, float, hlds_goal).
-:- mode make_float_const_construction(in, in, out) is det.
-
-:- pred make_char_const_construction(prog_var, char, hlds_goal).
-:- mode make_char_const_construction(in, in, out) is det.
-
-:- pred make_const_construction(prog_var, cons_id, hlds_goal).
-:- mode make_const_construction(in, in, out) is det.
-
-:- pred make_int_const_construction(int, maybe(string), hlds_goal, prog_var,
-	map(prog_var, type), map(prog_var, type), prog_varset, prog_varset).
-:- mode make_int_const_construction(in, in, out, out, in, out, in, out) is det.
-
-:- pred make_string_const_construction(string, maybe(string),
-	hlds_goal, prog_var, map(prog_var, type), map(prog_var, type),
-	prog_varset, prog_varset).
-:- mode make_string_const_construction(in, in, out, out, in, out, in, out)
-	is det.
-
-:- pred make_float_const_construction(float, maybe(string),
-	hlds_goal, prog_var, map(prog_var, type), map(prog_var, type),
-	prog_varset, prog_varset).
-:- mode make_float_const_construction(in, in, out, out, in, out, in, out)
-	is det.
-
-:- pred make_char_const_construction(char, maybe(string), hlds_goal, prog_var,
-	map(prog_var, type), map(prog_var, type), prog_varset, prog_varset).
-:- mode make_char_const_construction(in, in, out, out, in, out, in, out)
-	is det.
-
-:- pred make_const_construction(cons_id, (type), maybe(string),
-	hlds_goal, prog_var, map(prog_var, type), map(prog_var, type),
-	prog_varset, prog_varset).
-:- mode make_const_construction(in, in, in, out, out, in, out, in, out) is det.
-
-:- pred make_int_const_construction(int, maybe(string), hlds_goal, prog_var,
-	proc_info, proc_info).
-:- mode make_int_const_construction(in, in, out, out, in, out) is det.
-
-:- pred make_string_const_construction(string, maybe(string),
-	hlds_goal, prog_var, proc_info, proc_info).
-:- mode make_string_const_construction(in, in, out, out, in, out) is det.
-
-:- pred make_float_const_construction(float, maybe(string),
-	hlds_goal, prog_var, proc_info, proc_info).
-:- mode make_float_const_construction(in, in, out, out, in, out) is det.
-
-:- pred make_char_const_construction(char, maybe(string), hlds_goal, prog_var,
-	proc_info, proc_info).
-:- mode make_char_const_construction(in, in, out, out, in, out) is det.
-
-:- pred make_const_construction(cons_id, (type), maybe(string), hlds_goal,
-	prog_var, proc_info, proc_info).
-:- mode make_const_construction(in, in, in, out, out, in, out) is det.
+:- pred make_int_const_construction(prog_var::in, int::in,
+	hlds_goal::out) is det.
+:- pred make_string_const_construction(prog_var::in, string::in,
+	hlds_goal::out) is det.
+:- pred make_float_const_construction(prog_var::in, float::in,
+	hlds_goal::out) is det.
+:- pred make_char_const_construction(prog_var::in, char::in,
+	hlds_goal::out) is det.
+:- pred make_const_construction(prog_var::in, cons_id::in,
+	hlds_goal::out) is det.
+
+:- pred make_int_const_construction(int::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out,
+	vartypes::in, vartypes::out, prog_varset::in, prog_varset::out) is det.
+:- pred make_string_const_construction(string::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out,
+	vartypes::in, vartypes::out, prog_varset::in, prog_varset::out) is det.
+:- pred make_float_const_construction(float::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out,
+	vartypes::in, vartypes::out, prog_varset::in, prog_varset::out) is det.
+:- pred make_char_const_construction(char::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out,
+	vartypes::in, vartypes::out, prog_varset::in, prog_varset::out) is det.
+:- pred make_const_construction(cons_id::in, (type)::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out,
+	vartypes::in, vartypes::out, prog_varset::in, prog_varset::out) is det.
+
+:- pred make_int_const_construction(int::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out, proc_info::in, proc_info::out) is det.
+:- pred make_string_const_construction(string::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out, proc_info::in, proc_info::out) is det.
+:- pred make_float_const_construction(float::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out, proc_info::in, proc_info::out) is det.
+:- pred make_char_const_construction(char::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out, proc_info::in, proc_info::out) is det.
+:- pred make_const_construction(cons_id::in, (type)::in, maybe(string)::in,
+	hlds_goal::out, prog_var::out, proc_info::in, proc_info::out) is det.
 
 	% Given the variable info field from a pragma foreign_code, get all the
 	% variable names.
-:- pred get_pragma_foreign_var_names(list(maybe(pair(string, mode))),
-		list(string)).
-:- mode get_pragma_foreign_var_names(in, out) is det.
+:- pred get_pragma_foreign_var_names(list(maybe(pair(string, mode)))::in,
+	list(string)::out) is det.
 
 	%
 	% Produce a goal to construct or deconstruct a
@@ -1030,11 +949,10 @@
 	% determinism fields of the goal_info.
 	%
 
-:- pred construct_tuple(prog_var, list(prog_var), hlds_goal).
-:- mode construct_tuple(in, in, out) is det.
-
-:- pred deconstruct_tuple(prog_var, list(prog_var), hlds_goal).
-:- mode deconstruct_tuple(in, in, out) is det.
+:- pred construct_tuple(prog_var::in, list(prog_var)::in, hlds_goal::out)
+	is det.
+:- pred deconstruct_tuple(prog_var::in, list(prog_var)::in, hlds_goal::out)
+	is det.
 
 %-----------------------------------------------------------------------------%
 %
@@ -1090,19 +1008,16 @@
 			aditi_bulk_update,
 			pred_id,
 			aditi_builtin_syntax
-		)
-	.
+		).
 
 :- type aditi_tuple_update
 	--->	delete			% `aditi_delete'
-	;	insert			% `aditi_insert'
-	.
+	;	insert.			% `aditi_insert'
 
 :- type aditi_bulk_update
 	--->	bulk_delete		% `aditi_bulk_delete'
 	;	bulk_insert		% `aditi_bulk_insert'
-	;	bulk_modify		% `aditi_bulk_modify'
-	.
+	;	bulk_modify.		% `aditi_bulk_modify'
 
 	% Which syntax was used for an `aditi_delete' or `aditi_modify'
 	% call. The first syntax is prettier, the second is used
@@ -1112,12 +1027,11 @@
 :- type aditi_builtin_syntax
 	--->	pred_term		% e.g.
 					% aditi_bulk_insert(p(_, X) :- X = 1).
-	;	sym_name_and_closure	% e.g.
+	;	sym_name_and_closure.	% e.g.
 					% aditi_insert(p/2,
 					%    (pred(_::in, X::out) is nondet:-
 					%	X = 1)
 					%    )
-	.
 
 	% For lambda expressions built automatically for Aditi updates
 	% the modes of `aditi__state' arguments may need to be fixed
@@ -1126,8 +1040,7 @@
 	% arguments.
 :- type fix_aditi_state_modes
 	--->	modes_need_fixing
-	;	modes_are_ok
-	.
+	;	modes_are_ok.
 
 %-----------------------------------------------------------------------------%
 %
@@ -1150,7 +1063,7 @@
 :- import_module parse_tree__prog_util.
 :- import_module assoc_list, require, string, term, varset.
 
-:- import_module require, string, term, varset.
+:- import_module map, require, string, term, varset.
 
 %-----------------------------------------------------------------------------%
 %
@@ -1184,8 +1097,8 @@
 
 	% NB. Don't forget to check goal_util__name_apart_goalinfo
 	% if this structure is modified.
-:- type hlds_goal_info
-	---> goal_info(
+:- type hlds_goal_info --->
+	goal_info(
 		determinism :: determinism,
 				% the overall determinism of the goal
 				% (computed during determinism analysis)
@@ -1226,26 +1139,24 @@
 				% conservative approximation: it may be
 				% a superset of the real non-locals]
 
-		/*
-		code_gen_nonlocals :: maybe(set(prog_var)),
-				% the non-local vars in the goal,
-				% modified slightly for code generation.
-				% The difference between the code-gen nonlocals
-				% and the ordinary nonlocals is that arguments
-				% of a reconstruction which are taken from the
-				% reused cell are not considered to be
-				% `code_gen_nonlocals' of the goal.
-				% This avoids allocating stack slots and
-				% generating unnecessary field extraction
-				% instructions for those arguments.
-				% Mode information is still computed using
-				% the ordinary non-locals.
-				%
-				% If the field has value `no', the ordinary
-				% nonlocals are used instead. This will
-				% be the case if the procedure body does not
-				% contain any reconstructions.
-		*/
+% 		code_gen_nonlocals :: maybe(set(prog_var)),
+% 				% the non-local vars in the goal,
+% 				% modified slightly for code generation.
+% 				% The difference between the code-gen nonlocals
+% 				% and the ordinary nonlocals is that arguments
+% 				% of a reconstruction which are taken from the
+% 				% reused cell are not considered to be
+% 				% `code_gen_nonlocals' of the goal.
+% 				% This avoids allocating stack slots and
+% 				% generating unnecessary field extraction
+% 				% instructions for those arguments.
+% 				% Mode information is still computed using
+% 				% the ordinary non-locals.
+% 				%
+% 				% If the field has value `no', the ordinary
+% 				% nonlocals are used instead. This will
+% 				% be the case if the procedure body does not
+% 				% contain any reconstructions.
 
 		features :: set(goal_feature),
 				% The set of used-defined "features" of
@@ -1290,48 +1201,35 @@
 		list_to_set(Features), [], no_code_gen_info).
 
 goal_info_get_determinism(GoalInfo, GoalInfo ^ determinism).
-
 goal_info_get_instmap_delta(GoalInfo, GoalInfo ^ instmap_delta).
-
 goal_info_get_context(GoalInfo, GoalInfo ^ context).
-
 goal_info_get_nonlocals(GoalInfo, GoalInfo ^ nonlocals).
-
-	% The code-gen non-locals are always the same as the
-	% non-locals when structure reuse is not being performed.
-goal_info_get_code_gen_nonlocals(GoalInfo, NonLocals) :-
-	goal_info_get_nonlocals(GoalInfo, NonLocals).
-
 goal_info_get_features(GoalInfo, GoalInfo ^ features).
-
 goal_info_get_goal_path(GoalInfo, GoalInfo ^ goal_path).
-
 goal_info_get_code_gen_info(GoalInfo, GoalInfo ^ code_gen_info).
 
 goal_info_set_determinism(GoalInfo0, Determinism,
 		GoalInfo0 ^ determinism := Determinism).
-
 goal_info_set_instmap_delta(GoalInfo0, InstMapDelta,
 		GoalInfo0 ^ instmap_delta := InstMapDelta).
-
 goal_info_set_context(GoalInfo0, Context, GoalInfo0 ^ context := Context).
-
 goal_info_set_nonlocals(GoalInfo0, NonLocals,
 		GoalInfo0 ^ nonlocals := NonLocals).
-
-	% The code-gen non-locals are always the same as the
-	% non-locals when structure reuse is not being performed.
-goal_info_set_code_gen_nonlocals(GoalInfo0, NonLocals, GoalInfo) :-
-	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo).
-
 goal_info_set_features(GoalInfo0, Features, GoalInfo0 ^ features := Features).
-
 goal_info_set_goal_path(GoalInfo0, GoalPath,
 		GoalInfo0 ^ goal_path := GoalPath).
-
 goal_info_set_code_gen_info(GoalInfo0, CodeGenInfo,
 		GoalInfo0 ^ code_gen_info := CodeGenInfo).
 
+	% The code-gen non-locals are always the same as the
+	% non-locals when structure reuse is not being performed.
+goal_info_get_code_gen_nonlocals(GoalInfo, NonLocals) :-
+	goal_info_get_nonlocals(GoalInfo, NonLocals).
+	% The code-gen non-locals are always the same as the
+	% non-locals when structure reuse is not being performed.
+goal_info_set_code_gen_nonlocals(GoalInfo0, NonLocals, GoalInfo) :-
+	goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo).
+
 %-----------------------------------------------------------------------------%
 
 add_goal_info_purity_feature(GoalInfo0, Purity, GoalInfo) :-
@@ -1549,8 +1447,7 @@
 		NegatedGoal = not(Goal) - GoalInfo
 	).
 
-:- pred all_negated(list(hlds_goal), list(hlds_goal)).
-:- mode all_negated(in, out) is semidet.
+:- pred all_negated(list(hlds_goal)::in, list(hlds_goal)::out) is semidet.
 
 all_negated([], []).
 all_negated([not(Goal) - _ | NegatedGoals], [Goal | Goals]) :-
@@ -1561,8 +1458,10 @@
 	list__append(Goals1, Goals2, Goals).
 
 %-----------------------------------------------------------------------------%
-% Returns yes if a goal (or subgoal contained within) contains any foreign
-% code
+
+	% Returns yes if a goal (or subgoal contained within) contains
+	% any foreign code.
+
 goal_has_foreign(Goal) = HasForeign :-
 	Goal = GoalExpr - _,
 	(
@@ -1590,15 +1489,15 @@
 		GoalExpr = some(_, _, Goal2),
 		HasForeign = goal_has_foreign(Goal2)
 	;
-		GoalExpr = if_then_else(_, Goal2, Goal3, Goal4),
-		HasForeign =
-		(	goal_has_foreign(Goal2) = yes
-		->	yes
-		;	goal_has_foreign(Goal3) = yes
-		->	yes
-		;	goal_has_foreign(Goal4) = yes
-		->	yes
-		;	no
+		GoalExpr = if_then_else(_, Cond, Then, Else),
+		( goal_has_foreign(Cond) = yes ->
+			HasForeign = yes
+		; goal_has_foreign(Then) = yes ->
+			HasForeign = yes
+		; goal_has_foreign(Else) = yes ->
+			HasForeign = yes
+		;
+			HasForeign = no
 		)
 	;
 		GoalExpr = foreign_proc(_, _, _, _, _, _, _),
@@ -1613,22 +1512,22 @@
 
 	% Return yes if the shorthand goal contains any foreign code
 :- func goal_has_foreign_shorthand(shorthand_goal_expr) = bool.
-:- mode goal_has_foreign_shorthand(in) = out is det.
 
 goal_has_foreign_shorthand(bi_implication(Goal2, Goal3)) = HasForeign :-
-	HasForeign =
-	(	goal_has_foreign(Goal2) = yes
-	->	yes
-	;	goal_has_foreign(Goal3) = yes
-	->	yes
-	;	no
+	( goal_has_foreign(Goal2) = yes ->
+		HasForeign = yes
+	; goal_has_foreign(Goal3) = yes ->
+		HasForeign = yes
+	;
+		HasForeign = no
 	).
 
 goal_list_has_foreign([]) = no.
 goal_list_has_foreign([X | Xs]) =
-	(	goal_has_foreign(X) = yes
-	->	yes
-	;	goal_list_has_foreign(Xs)
+	( goal_has_foreign(X) = yes ->
+		yes
+	;
+		goal_list_has_foreign(Xs)
 	).
 
 %-----------------------------------------------------------------------------%
@@ -1688,11 +1587,11 @@
        list__foldl(ComputeDeterminism, Goals, det, Determinism).
 
 goal_list_purity(Goals, Purity) :-
-	Purity = list__foldl(
-			(func(_ - GoalInfo, Purity0) = Purity1 :-
+	ComputePurity = (func(_ - GoalInfo, Purity0) = Purity1 :-
 				infer_goal_info_purity(GoalInfo, GoalPurity),
 		    		worst_purity(GoalPurity, Purity0) = Purity1
-			), Goals, pure).
+		),
+	Purity = list__foldl(ComputePurity, Goals, pure).
 
 %-----------------------------------------------------------------------------%
 
@@ -1700,8 +1599,8 @@
 	goal_info_set_context(GoalInfo0, Context, GoalInfo),
 	set_goal_contexts_2(Context, Goal0, Goal).
 
-:- pred set_goal_contexts_2(prog_context, hlds_goal_expr, hlds_goal_expr).
-:- mode set_goal_contexts_2(in, in, out) is det.
+:- pred set_goal_contexts_2(prog_context::in, hlds_goal_expr::in,
+	hlds_goal_expr::out) is det.
 
 set_goal_contexts_2(Context, conj(Goals0), conj(Goals)) :-
 	list__map(set_goal_contexts(Context), Goals0, Goals).
@@ -1717,7 +1616,8 @@
 set_goal_contexts_2(Context, switch(Var, CanFail, Cases0),
 		switch(Var, CanFail, Cases)) :-
 	list__map(
-	    (pred(case(ConsId, Goal0)::in, case(ConsId, Goal)::out) is det :-
+		(pred(case(ConsId, Goal0)::in, case(ConsId, Goal)::out)
+				is det :-
 		set_goal_contexts(Context, Goal0, Goal)
 	    ), Cases0, Cases).
 set_goal_contexts_2(Context, some(Vars, CanRemove, Goal0),
@@ -1738,9 +1638,8 @@
 	set_goal_contexts_2_shorthand(Context, ShorthandGoal0,
 		ShorthandGoal).
 
-:- pred set_goal_contexts_2_shorthand(prog_context, shorthand_goal_expr,
-		shorthand_goal_expr).
-:- mode set_goal_contexts_2_shorthand(in, in, out) is det.
+:- pred set_goal_contexts_2_shorthand(prog_context::in,
+	shorthand_goal_expr::in, shorthand_goal_expr::out) is det.
 
 set_goal_contexts_2_shorthand(Context, bi_implication(LHS0, RHS0),
 		bi_implication(LHS, RHS)) :-
@@ -1749,14 +1648,14 @@
 
 %-----------------------------------------------------------------------------%
 
-create_atomic_unification(A, B, Context, UnifyMainContext, UnifySubContext,
+create_atomic_unification(LHS, RHS, Context, UnifyMainContext, UnifySubContext,
 		Goal) :-
 	UMode = ((free - free) -> (free - free)),
 	Mode = ((free -> free) - (free -> free)),
 	UnifyInfo = complicated_unify(UMode, can_fail, []),
 	UnifyC = unify_context(UnifyMainContext, UnifySubContext),
 	goal_info_init(Context, GoalInfo),
-	Goal = unify(A, B, Mode, UnifyInfo, UnifyC) - GoalInfo.
+	Goal = unify(LHS, RHS, Mode, UnifyInfo, UnifyC) - GoalInfo.
 
 %-----------------------------------------------------------------------------%
 
@@ -1880,16 +1779,15 @@
 :- pred get_pragma_foreign_var_names_2(list(maybe(pair(string, mode)))::in,
 	list(string)::in, list(string)::out) is det.
 
-get_pragma_foreign_var_names_2([], Names, Names).
-get_pragma_foreign_var_names_2([MaybeName | MaybeNames], Names0, Names) :-
+get_pragma_foreign_var_names_2([], !Names).
+get_pragma_foreign_var_names_2([MaybeName | MaybeNames], !Names) :-
 	(
 		MaybeName = yes(Name - _),
-		Names1 = [Name | Names0]
+		!:Names = [Name | !.Names]
 	;
-		MaybeName = no,
-		Names1 = Names0
+		MaybeName = no
 	),
-	get_pragma_foreign_var_names_2(MaybeNames, Names1, Names).
+	get_pragma_foreign_var_names_2(MaybeNames, !Names).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/modecheck_call.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_call.m,v
retrieving revision 1.48
diff -u -b -r1.48 modecheck_call.m
--- compiler/modecheck_call.m	6 Nov 2003 03:42:35 -0000	1.48
+++ compiler/modecheck_call.m	28 Mar 2004 19:04:48 -0000
@@ -30,28 +30,23 @@
 
 :- import_module list, std_util.
 
-:- pred modecheck_call_pred(pred_id, proc_id, list(prog_var),
-		maybe(determinism), proc_id, list(prog_var),
-		extra_goals, mode_info, mode_info).
-:- mode modecheck_call_pred(in, in, in, in, out, out, out,
-		in, out) is det.
-
-:- pred modecheck_higher_order_call(pred_or_func, prog_var, list(prog_var),
-		list(mode), determinism, list(prog_var),
-		extra_goals, mode_info, mode_info).
-:- mode modecheck_higher_order_call(in, in, in, out, out, out, out,
-		in, out) is det.
-
-:- pred modecheck_aditi_builtin(aditi_builtin, simple_call_id,
-		list(prog_var), list(mode), determinism,
-		list(prog_var), extra_goals, mode_info, mode_info).
-:- mode modecheck_aditi_builtin(in, in, in, in, out, out, out,
-		in, out) is det.
-
-:- pred modecheck_builtin_cast(list(prog_var), list(mode), determinism,
-		list(prog_var), extra_goals, mode_info, mode_info).
-:- mode modecheck_builtin_cast(in, in, out, out, out,
-		in, out) is det.
+:- pred modecheck_call_pred(pred_id::in, maybe(determinism)::in,
+	proc_id::in, proc_id::out, list(prog_var)::in, list(prog_var)::out,
+	extra_goals::out, mode_info::in, mode_info::out) is det.
+
+:- pred modecheck_higher_order_call(pred_or_func::in, prog_var::in,
+	list(prog_var)::in, list(prog_var)::out, list(mode)::out,
+	determinism::out, extra_goals::out,
+	mode_info::in, mode_info::out) is det.
+
+:- pred modecheck_aditi_builtin(aditi_builtin::in, simple_call_id::in,
+	list(mode)::in, list(prog_var)::in, list(prog_var)::out,
+	determinism::out, extra_goals::out,
+	mode_info::in, mode_info::out) is det.
+
+:- pred modecheck_builtin_cast(list(mode)::in,
+	list(prog_var)::in, list(prog_var)::out, determinism::out,
+	extra_goals::out, mode_info::in, mode_info::out) is det.
 
 	%
 	% Given two modes of a predicate, figure out whether
@@ -61,8 +56,8 @@
 	% Note that mode declarations which only have different final insts
 	% do not count as distinguishable.
 	%
-:- pred modes_are_indistinguishable(proc_id, proc_id, pred_info, module_info).
-:- mode modes_are_indistinguishable(in, in, in, in) is semidet.
+:- pred modes_are_indistinguishable(proc_id::in, proc_id::in, pred_info::in,
+	module_info::in) is semidet.
 
 	%
 	% Given two modes of a predicate, figure out whether
@@ -72,8 +67,8 @@
 	% a multi mode for a cc_multi one if the call occurs in a
 	% non-cc context.
 	%
-:- pred modes_are_identical_bar_cc(proc_id, proc_id, pred_info, module_info).
-:- mode modes_are_identical_bar_cc(in, in, in, in) is semidet.
+:- pred modes_are_identical_bar_cc(proc_id::in, proc_id::in, pred_info::in,
+	module_info::in) is semidet.
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
@@ -98,123 +93,13 @@
 
 :- import_module int, map, bool, set, require, term, varset.
 
-modecheck_higher_order_call(PredOrFunc, PredVar, Args0, Modes, Det,
-		Args, ExtraGoals, ModeInfo0, ModeInfo) :-
-	%
-	% First, check that `PredVar' has a higher-order pred inst
-	% (of the appropriate arity)
-	%
-	mode_info_get_instmap(ModeInfo0, InstMap0),
-	instmap__lookup_var(InstMap0, PredVar, PredVarInst0),
-	mode_info_get_module_info(ModeInfo0, ModuleInfo0),
-	inst_expand(ModuleInfo0, PredVarInst0, PredVarInst),
-	list__length(Args0, Arity),
-	(
-		PredVarInst = ground(_Uniq, GroundInstInfo),
-		(
-			GroundInstInfo = higher_order(PredInstInfo)
-		;
-			% If PredVar has no higher-order inst
-			% information, but is a function type, then
-			% assume the default function mode.
-			GroundInstInfo = none,
-			mode_info_get_var_types(ModeInfo0, VarTypes),
-			map__lookup(VarTypes, PredVar, Type),
-			type_is_higher_order(Type, _Purity, function, _,
-				ArgTypes),
-			PredInstInfo = pred_inst_info_standard_func_mode(
-					list__length(ArgTypes))
-		),
-		PredInstInfo = pred_inst_info(PredOrFunc, Modes0, Det0),
-		list__length(Modes0, Arity)
-	->
-		Det = Det0,
-		Modes = Modes0,
-		ArgOffset = 1,
-		modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args,
-			ModeInfo0, ModeInfo1),
-
-		( determinism_components(Det, _, at_most_zero) ->
-			instmap__init_unreachable(Instmap),
-			mode_info_set_instmap(Instmap, ModeInfo1, ModeInfo)
-		;
-			ModeInfo = ModeInfo1
-		)
-	;
-		% the error occurred in argument 1, i.e. the pred term
-		mode_info_set_call_arg_context(1, ModeInfo0, ModeInfo1),
-		set__singleton_set(WaitingVars, PredVar),
-		mode_info_error(WaitingVars, mode_error_higher_order_pred_var(
-				PredOrFunc, PredVar, PredVarInst, Arity),
-				ModeInfo1, ModeInfo),
-		Modes = [],
-		Det = erroneous,
-		Args = Args0,
-		ExtraGoals = no_extra_goals
-	).
-
-modecheck_aditi_builtin(AditiBuiltin, _, Args0, Modes, Det,
-		Args, ExtraGoals) -->
-	{ aditi_builtin_determinism(AditiBuiltin, Det) },
-
-	% The argument modes are set by post_typecheck.m, so all
-	% that needs to be done here is to check that they match.
-	{ ArgOffset = 0 },
-	modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args).
-
-:- pred aditi_builtin_determinism(aditi_builtin, determinism).
-:- mode aditi_builtin_determinism(in, out) is det.
-
-aditi_builtin_determinism(aditi_tuple_update(_, _), det).
-aditi_builtin_determinism(aditi_bulk_update(_, _, _), det).
-
-modecheck_builtin_cast(Args0, Modes, Det, Args, ExtraGoals) -->
-	{ Det = det },
-	% These should always be mode correct.
-	{ ArgOffset = 0 },
-	modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args).
-
-:- pred modecheck_arg_list(int, list(mode), extra_goals,
-		list(prog_var), list(prog_var), mode_info, mode_info).
-:- mode modecheck_arg_list(in, in, out, in, out,
-		in, out) is det.
-
-modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args,
-		ModeInfo0, ModeInfo) :-
-
-	%
-	% Check that `Args0' have livenesses which match the
-	% expected livenesses.
-	%
-	mode_info_get_module_info(ModeInfo0, ModuleInfo0),
-	get_arg_lives(Modes, ModuleInfo0, ExpectedArgLives),
-	NeedExactMatch = no,
-	modecheck_var_list_is_live(Args0, ExpectedArgLives, NeedExactMatch,
-		ArgOffset, ModeInfo0, ModeInfo1),
-
-	%
-	% Check that `Args0' have insts which match the expected
-	% initial insts, and set their new final insts (introducing
-	% extra unifications for implied modes, if necessary).
-	%
-	mode_list_get_initial_insts(Modes, ModuleInfo0, InitialInsts),
-	modecheck_var_has_inst_list(Args0, InitialInsts, NeedExactMatch,
-		ArgOffset, InstVarSub, ModeInfo1, ModeInfo2),
-	mode_list_get_final_insts(Modes, ModuleInfo0, FinalInsts0),
-	inst_list_apply_substitution(FinalInsts0, InstVarSub, FinalInsts),
-	modecheck_set_var_inst_list(Args0, InitialInsts, FinalInsts,
-		ArgOffset, Args, ExtraGoals, ModeInfo2, ModeInfo).
-
-modecheck_call_pred(PredId, ProcId0, ArgVars0, DeterminismKnown,
-		TheProcId, ArgVars, ExtraGoals, ModeInfo0, ModeInfo) :-
-
-	mode_info_get_may_change_called_proc(ModeInfo0, MayChangeCalledProc),
-
-	mode_info_get_preds(ModeInfo0, Preds),
-	mode_info_get_module_info(ModeInfo0, ModuleInfo),
+modecheck_call_pred(PredId, DeterminismKnown, ProcId0, TheProcId,
+		ArgVars0, ArgVars, ExtraGoals, !ModeInfo) :-
+	mode_info_get_may_change_called_proc(!.ModeInfo, MayChangeCalledProc),
+	mode_info_get_preds(!.ModeInfo, Preds),
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo),
 	map__lookup(Preds, PredId, PredInfo),
 	pred_info_procedures(PredInfo, Procs),
-
 	( MayChangeCalledProc = may_not_change_called_proc ->
 		( ProcId0 = invalid_proc_id ->
 			error("modecheck_call_pred: invalid proc_id")
@@ -239,7 +124,7 @@
 	->
 		set__init(WaitingVars),
 		mode_info_error(WaitingVars, mode_error_no_mode_decl,
-			ModeInfo0, ModeInfo),
+			!ModeInfo),
 		TheProcId = invalid_proc_id,
 		ArgVars = ArgVars0,
 		ExtraGoals = no_extra_goals
@@ -259,7 +144,7 @@
 		proc_info_arglives(ProcInfo, ModuleInfo, ProcArgLives0),
 		NeedExactMatch = no,
 		modecheck_var_list_is_live(ArgVars0, ProcArgLives0,
-			NeedExactMatch, ArgOffset, ModeInfo0, ModeInfo1),
+			NeedExactMatch, ArgOffset, !ModeInfo),
 
 		%
 		% Check that `ArgsVars0' have insts which match the expected
@@ -268,43 +153,40 @@
 		%
 		proc_info_argmodes(ProcInfo, ProcArgModes0),
 		proc_info_inst_varset(ProcInfo, ProcInstVarSet),
-		mode_info_get_instvarset(ModeInfo1, InstVarSet),
+		mode_info_get_instvarset(!.ModeInfo, InstVarSet),
 		rename_apart_inst_vars(InstVarSet, ProcInstVarSet,
 			ProcArgModes0, ProcArgModes),
 		mode_list_get_initial_insts(ProcArgModes, ModuleInfo,
 				InitialInsts),
 		modecheck_var_has_inst_list(ArgVars0, InitialInsts,
-				NeedExactMatch, ArgOffset, InstVarSub,
-				ModeInfo1, ModeInfo2),
+			NeedExactMatch, ArgOffset, InstVarSub, !ModeInfo),
 
 		modecheck_end_of_call(ProcInfo, ProcArgModes, ArgVars0,
-			ArgOffset, InstVarSub, ArgVars, ExtraGoals, ModeInfo2,
-			ModeInfo)
+			ArgOffset, InstVarSub, ArgVars, ExtraGoals, !ModeInfo)
 	;
 			% set the current error list to empty (and
 			% save the old one in `OldErrors').  This is so the
 			% test for `Errors = []' in find_matching_modes
 			% will work.
-		mode_info_get_errors(ModeInfo0, OldErrors),
-		mode_info_set_errors([], ModeInfo0, ModeInfo1),
+		mode_info_get_errors(!.ModeInfo, OldErrors),
+		mode_info_set_errors([], !ModeInfo),
 
 		set__init(WaitingVars0),
 		modecheck_find_matching_modes(ProcIds, PredId, Procs, ArgVars0,
 			[], RevMatchingProcIds, WaitingVars0, WaitingVars1,
-			ModeInfo1, ModeInfo2),
+			!ModeInfo),
 
 		(	RevMatchingProcIds = [],
-			no_matching_modes(PredId, ArgVars0,
-				DeterminismKnown, WaitingVars1,
-				TheProcId, ModeInfo2, ModeInfo4),
+			no_matching_modes(PredId, ArgVars0, DeterminismKnown,
+				WaitingVars1, TheProcId, !ModeInfo),
 			ArgVars = ArgVars0,
 			ExtraGoals = no_extra_goals
 		;
 			RevMatchingProcIds = [_|_],
 			list__reverse(RevMatchingProcIds, MatchingProcIds),
-			choose_best_match(MatchingProcIds, PredId, Procs,
-				ArgVars0, TheProcId, InstVarSub, ProcArgModes,
-				ModeInfo2),
+			choose_best_match(!.ModeInfo, MatchingProcIds,
+				PredId, Procs, ArgVars0, TheProcId, InstVarSub,
+				ProcArgModes),
 			map__lookup(Procs, TheProcId, ProcInfo),
 			CalleeModeErrors = ProcInfo ^ mode_errors,
 			( CalleeModeErrors = [_|_] ->
@@ -312,99 +194,201 @@
 				ArgVars = ArgVars0,
 				WaitingVars = set__list_to_set(ArgVars),
 				ExtraGoals = no_extra_goals,
-				mode_info_get_instmap(ModeInfo2, InstMap),
+				mode_info_get_instmap(!.ModeInfo, InstMap),
 				instmap__lookup_vars(ArgVars, InstMap,
 					ArgInsts),
-				mode_info_set_call_arg_context(0, ModeInfo2,
-					ModeInfo3),
+				mode_info_set_call_arg_context(0, !ModeInfo),
 				mode_info_error(WaitingVars,
 					mode_error_in_callee(ArgVars, ArgInsts,
 						PredId, TheProcId,
 						CalleeModeErrors),
-					ModeInfo3, ModeInfo4)
+					!ModeInfo)
 			;
 				modecheck_end_of_call(ProcInfo, ProcArgModes,
 					ArgVars0, ArgOffset, InstVarSub,
-					ArgVars, ExtraGoals,
-					ModeInfo2, ModeInfo4)
+					ArgVars, ExtraGoals, !ModeInfo)
 			)
 		),
 
 			% restore the error list, appending any new error(s)
-		mode_info_get_errors(ModeInfo4, NewErrors),
+		mode_info_get_errors(!.ModeInfo, NewErrors),
 		list__append(OldErrors, NewErrors, Errors),
-		mode_info_set_errors(Errors, ModeInfo4, ModeInfo)
+		mode_info_set_errors(Errors, !ModeInfo)
 	).
 
-%--------------------------------------------------------------------------%
+modecheck_higher_order_call(PredOrFunc, PredVar, Args0, Args, Modes, Det,
+		ExtraGoals, !ModeInfo) :-
+	%
+	% First, check that `PredVar' has a higher-order pred inst
+	% (of the appropriate arity)
+	%
+	mode_info_get_instmap(!.ModeInfo, InstMap0),
+	instmap__lookup_var(InstMap0, PredVar, PredVarInst0),
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
+	inst_expand(ModuleInfo0, PredVarInst0, PredVarInst),
+	list__length(Args0, Arity),
+	(
+		PredVarInst = ground(_Uniq, GroundInstInfo),
+		(
+			GroundInstInfo = higher_order(PredInstInfo)
+		;
+			% If PredVar has no higher-order inst
+			% information, but is a function type, then
+			% assume the default function mode.
+			GroundInstInfo = none,
+			mode_info_get_var_types(!.ModeInfo, VarTypes),
+			map__lookup(VarTypes, PredVar, Type),
+			type_is_higher_order(Type, _Purity, function, _,
+				ArgTypes),
+			PredInstInfo = pred_inst_info_standard_func_mode(
+				list__length(ArgTypes))
+		),
+		PredInstInfo = pred_inst_info(PredOrFunc, Modes0, Det0),
+		list__length(Modes0, Arity)
+	->
+		Det = Det0,
+		Modes = Modes0,
+		ArgOffset = 1,
+		modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args,
+			!ModeInfo),
 
-:- pred no_matching_modes(pred_id, list(prog_var), maybe(determinism),
-		set(prog_var), proc_id, mode_info, mode_info).
-:- mode no_matching_modes(in, in, in, in, out, in, out)
+		( determinism_components(Det, _, at_most_zero) ->
+			instmap__init_unreachable(Instmap),
+			mode_info_set_instmap(Instmap, !ModeInfo)
+		;
+			true
+		)
+	;
+		% the error occurred in argument 1, i.e. the pred term
+		mode_info_set_call_arg_context(1, !ModeInfo),
+		set__singleton_set(WaitingVars, PredVar),
+		mode_info_error(WaitingVars,
+			mode_error_higher_order_pred_var(
+				PredOrFunc, PredVar, PredVarInst, Arity),
+			!ModeInfo),
+		Modes = [],
+		Det = erroneous,
+		Args = Args0,
+		ExtraGoals = no_extra_goals
+	).
+
+modecheck_aditi_builtin(AditiBuiltin, _, Modes, Args0, Args, Det, ExtraGoals,
+		!ModeInfo) :-
+	aditi_builtin_determinism(AditiBuiltin, Det),
+
+	% The argument modes are set by post_typecheck.m, so all
+	% that needs to be done here is to check that they match.
+	ArgOffset = 0,
+	modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args,
+		!ModeInfo).
+
+:- pred aditi_builtin_determinism(aditi_builtin::in, determinism::out) is det.
+
+aditi_builtin_determinism(aditi_tuple_update(_, _), det).
+aditi_builtin_determinism(aditi_bulk_update(_, _, _), det).
+
+modecheck_builtin_cast(Modes, Args0, Args, Det, ExtraGoals, !ModeInfo) :-
+	Det = det,
+	% These should always be mode correct.
+	ArgOffset = 0,
+	modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args,
+		!ModeInfo).
+
+%-----------------------------------------------------------------------------%
+
+:- pred modecheck_arg_list(int::in, list(mode)::in, extra_goals::out,
+	list(prog_var)::in, list(prog_var)::out, mode_info::in, mode_info::out)
 	is det.
 
+modecheck_arg_list(ArgOffset, Modes, ExtraGoals, Args0, Args, !ModeInfo) :-
+
+	%
+	% Check that `Args0' have livenesses which match the
+	% expected livenesses.
+	%
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
+	get_arg_lives(Modes, ModuleInfo0, ExpectedArgLives),
+	NeedExactMatch = no,
+	modecheck_var_list_is_live(Args0, ExpectedArgLives, NeedExactMatch,
+		ArgOffset, !ModeInfo),
+
+	%
+	% Check that `Args0' have insts which match the expected
+	% initial insts, and set their new final insts (introducing
+	% extra unifications for implied modes, if necessary).
+	%
+	mode_list_get_initial_insts(Modes, ModuleInfo0, InitialInsts),
+	modecheck_var_has_inst_list(Args0, InitialInsts, NeedExactMatch,
+		ArgOffset, InstVarSub, !ModeInfo),
+	mode_list_get_final_insts(Modes, ModuleInfo0, FinalInsts0),
+	inst_list_apply_substitution(FinalInsts0, InstVarSub, FinalInsts),
+	modecheck_set_var_inst_list(Args0, InitialInsts, FinalInsts,
+		ArgOffset, Args, ExtraGoals, !ModeInfo).
+
+%--------------------------------------------------------------------------%
+
+:- pred no_matching_modes(pred_id::in, list(prog_var)::in,
+	maybe(determinism)::in, set(prog_var)::in, proc_id::out,
+	mode_info::in, mode_info::out) is det.
+
 no_matching_modes(PredId, ArgVars, DeterminismKnown, WaitingVars, TheProcId,
-		ModeInfo0, ModeInfo) :-
+		!ModeInfo) :-
 	%
 	% There were no matching modes.
 	% If we're inferring modes for this called predicate, then
 	% just insert a new mode declaration which will match.
 	% Otherwise, report an error.
 	%
-	mode_info_get_preds(ModeInfo0, Preds),
+	mode_info_get_preds(!.ModeInfo, Preds),
 	map__lookup(Preds, PredId, PredInfo),
 	pred_info_get_markers(PredInfo, Markers),
 	( check_marker(Markers, infer_modes) ->
 		insert_new_mode(PredId, ArgVars, DeterminismKnown, TheProcId,
-			ModeInfo0, ModeInfo1),
+			!ModeInfo),
 		% we don't yet know the final insts for the newly created mode
 		% of the called predicate, so we set the instmap to unreachable,
 		% indicating that we have no information about the modes at this
 		% point in the computation.
 		instmap__init_unreachable(Instmap),
-		mode_info_set_instmap(Instmap, ModeInfo1, ModeInfo)
+		mode_info_set_instmap(Instmap, !ModeInfo)
 	;
 		TheProcId = invalid_proc_id,	% dummy value
-		mode_info_get_instmap(ModeInfo0, InstMap),
+		mode_info_get_instmap(!.ModeInfo, InstMap),
 		instmap__lookup_vars(ArgVars, InstMap, ArgInsts),
-		mode_info_set_call_arg_context(0, ModeInfo0, ModeInfo1),
+		mode_info_set_call_arg_context(0, !ModeInfo),
 		mode_info_error(WaitingVars,
 			mode_error_no_matching_mode(ArgVars, ArgInsts),
-			ModeInfo1, ModeInfo)
+			!ModeInfo)
 	).
 
 :- type proc_mode ---> proc_mode(proc_id, inst_var_sub, list(mode)).
 
-:- pred modecheck_find_matching_modes(list(proc_id), pred_id, proc_table,
-		list(prog_var), list(proc_mode), list(proc_mode), set(prog_var),
-		set(prog_var), mode_info, mode_info).
-:- mode modecheck_find_matching_modes(in, in, in, in,
-			in, out, in, out, in, out) is det.
+:- pred modecheck_find_matching_modes(list(proc_id)::in, pred_id::in,
+	proc_table::in, list(prog_var)::in, list(proc_mode)::in,
+	list(proc_mode)::out, set(prog_var)::in, set(prog_var)::out,
+	mode_info::in, mode_info::out) is det.
 
 modecheck_find_matching_modes([], _PredId, _Procs, _ArgVars,
-			MatchingProcIds, MatchingProcIds,
-			WaitingVars, WaitingVars, ModeInfo, ModeInfo).
-
+		!MatchingProcIds, !WaitingVars, !ModeInfo).
 modecheck_find_matching_modes([ProcId | ProcIds], PredId, Procs, ArgVars0,
-			MatchingProcIds0, MatchingProcIds,
-			WaitingVars0, WaitingVars, ModeInfo0, ModeInfo) :-
+		!MatchingProcIds, !WaitingVars, !ModeInfo) :-
 
 		% find the initial insts and the final livenesses
 		% of the arguments for this mode of the called pred
 	map__lookup(Procs, ProcId, ProcInfo),
 	proc_info_argmodes(ProcInfo, ProcArgModes0),
 	proc_info_inst_varset(ProcInfo, ProcInstVarSet),
-	mode_info_get_instvarset(ModeInfo0, InstVarSet),
+	mode_info_get_instvarset(!.ModeInfo, InstVarSet),
 	rename_apart_inst_vars(InstVarSet, ProcInstVarSet, ProcArgModes0,
 		ProcArgModes),
-	mode_info_get_module_info(ModeInfo0, ModuleInfo),
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo),
 	proc_info_arglives(ProcInfo, ModuleInfo, ProcArgLives0),
 
 		% check whether the livenesses of the args matches their
 		% expected liveness
 	NeedLivenessExactMatch = no,
 	modecheck_var_list_is_live(ArgVars0, ProcArgLives0,
-			NeedLivenessExactMatch, 0, ModeInfo0, ModeInfo1),
+		NeedLivenessExactMatch, 0, !ModeInfo),
 
 		% If we're doing mode inference for the called
 		% procedure, and the called procedure has been inferred as
@@ -415,9 +399,7 @@
 		% Would it be better to always require an exact match when
 		% doing mode inference, to ensure that we add new inferred
 		% modes rather than using implied modes?
-	(
-		proc_info_is_valid_mode(ProcInfo)
-	->
+	( proc_info_is_valid_mode(ProcInfo) ->
 		NeedExactMatch = no
 	;
 		NeedExactMatch = yes
@@ -427,57 +409,52 @@
 		% initial insts. 
 	mode_list_get_initial_insts(ProcArgModes, ModuleInfo, InitialInsts),
 	modecheck_var_has_inst_list(ArgVars0, InitialInsts, NeedExactMatch, 0,
-			InstVarSub, ModeInfo1, ModeInfo2),
+		InstVarSub, !ModeInfo),
 
 		% If we got an error, reset the error list
 		% and save the list of vars to wait on.
 		% Otherwise, insert the proc_id in the list of matching
 		% proc_ids.
-	mode_info_get_errors(ModeInfo2, Errors),
+	mode_info_get_errors(!.ModeInfo, Errors),
 	(
-		Errors = [FirstError | _]
-	->
-		MatchingProcIds1 = MatchingProcIds0,
-		mode_info_set_errors([], ModeInfo2, ModeInfo3),
+		Errors = [FirstError | _],
+		mode_info_set_errors([], !ModeInfo),
 		FirstError = mode_error_info(ErrorWaitingVars, _, _, _),
-		set__union(WaitingVars0, ErrorWaitingVars, WaitingVars1)
+		set__union(!.WaitingVars, ErrorWaitingVars, !:WaitingVars)
 	;
-		MatchingProcIds1 = [proc_mode(ProcId, InstVarSub, ProcArgModes)
-					| MatchingProcIds0],
-		ModeInfo3 = ModeInfo2,
-		WaitingVars1 = WaitingVars0
+		Errors = [],
+		NewMatch = proc_mode(ProcId, InstVarSub, ProcArgModes),
+		!:MatchingProcIds = [NewMatch | !.MatchingProcIds]
 	),
 
 		% keep trying with the other modes for the called pred
 	modecheck_find_matching_modes(ProcIds, PredId, Procs, ArgVars0,
-			MatchingProcIds1, MatchingProcIds,
-			WaitingVars1, WaitingVars, ModeInfo3, ModeInfo).
+		!MatchingProcIds, !WaitingVars, !ModeInfo).
 
-:- pred modecheck_end_of_call(proc_info, list(mode), list(prog_var), int,
-	inst_var_sub, list(prog_var), extra_goals, mode_info, mode_info).
-:- mode modecheck_end_of_call(in, in, in, in, in, out, out,
-				in, out) is det.
+:- pred modecheck_end_of_call(proc_info::in, list(mode)::in,
+	list(prog_var)::in, int::in, inst_var_sub::in, list(prog_var)::out,
+	extra_goals::out, mode_info::in, mode_info::out) is det.
 
 modecheck_end_of_call(ProcInfo, ProcArgModes, ArgVars0, ArgOffset, InstVarSub,
-			ArgVars, ExtraGoals, ModeInfo0, ModeInfo) :-
-	mode_info_get_module_info(ModeInfo0, ModuleInfo),
+		ArgVars, ExtraGoals, !ModeInfo) :-
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo),
 	mode_list_get_initial_insts(ProcArgModes, ModuleInfo, InitialInsts0),
 	inst_list_apply_substitution(InitialInsts0, InstVarSub, InitialInsts),
 	mode_list_get_final_insts(ProcArgModes, ModuleInfo, FinalInsts0),
 	inst_list_apply_substitution(FinalInsts0, InstVarSub, FinalInsts),
 	modecheck_set_var_inst_list(ArgVars0, InitialInsts, FinalInsts,
-			ArgOffset, ArgVars, ExtraGoals, ModeInfo0, ModeInfo1),
+		ArgOffset, ArgVars, ExtraGoals, !ModeInfo),
 	proc_info_never_succeeds(ProcInfo, NeverSucceeds),
 	( NeverSucceeds = yes ->
 		instmap__init_unreachable(Instmap),
-		mode_info_set_instmap(Instmap, ModeInfo1, ModeInfo)
+		mode_info_set_instmap(Instmap, !ModeInfo)
 	;
-		ModeInfo = ModeInfo1
+		true
 	).
 
-:- pred insert_new_mode(pred_id, list(prog_var), maybe(determinism), proc_id,
-			mode_info, mode_info).
-:- mode insert_new_mode(in, in, in, out, in, out) is det.
+:- pred insert_new_mode(pred_id::in, list(prog_var)::in,
+	maybe(determinism)::in, proc_id::out,
+	mode_info::in, mode_info::out) is det.
 
 	% Insert a new inferred mode for a predicate.
 	% The initial insts are determined by using a normalised
@@ -485,18 +462,18 @@
 	% The final insts are initially just assumed to be all `not_reached'.
 	% The determinism for this mode will be inferred.
 
-insert_new_mode(PredId, ArgVars, MaybeDet, ProcId, ModeInfo0, ModeInfo) :-
+insert_new_mode(PredId, ArgVars, MaybeDet, ProcId, !ModeInfo) :-
 	% figure out the values of all the variables we need to
 	% create a new mode for this predicate
-	get_var_insts_and_lives(ArgVars, ModeInfo0, InitialInsts, ArgLives),
-	mode_info_get_module_info(ModeInfo0, ModuleInfo0),
+	get_var_insts_and_lives(ArgVars, !.ModeInfo, InitialInsts, ArgLives),
+	mode_info_get_module_info(!.ModeInfo, ModuleInfo0),
 	module_info_preds(ModuleInfo0, Preds0),
 	map__lookup(Preds0, PredId, PredInfo0),
 	pred_info_context(PredInfo0, Context),
 	list__length(ArgVars, Arity),
 	list__duplicate(Arity, not_reached, FinalInsts),
 	inst_lists_to_mode_list(InitialInsts, FinalInsts, Modes),
-	mode_info_get_instvarset(ModeInfo0, InstVarSet),
+	mode_info_get_instvarset(!.ModeInfo, InstVarSet),
 
 	%
 	% call unify_proc__request_proc, which will
@@ -506,16 +483,15 @@
 	unify_proc__request_proc(PredId, Modes, InstVarSet, yes(ArgLives),
 		MaybeDet, Context, ProcId, ModuleInfo0, ModuleInfo),
 
-	mode_info_set_module_info(ModuleInfo, ModeInfo0, ModeInfo1),
+	mode_info_set_module_info(ModuleInfo, !ModeInfo),
 
 	% Since we've created a new inferred mode for this predicate,
 	% things have changed, so we will need to do at least one more
 	% pass of the fixpoint analysis.
-	mode_info_set_changed_flag(yes, ModeInfo1, ModeInfo).
+	mode_info_set_changed_flag(yes, !ModeInfo).
 
-:- pred get_var_insts_and_lives(list(prog_var), mode_info,
-				list(inst), list(is_live)).
-:- mode get_var_insts_and_lives(in, in, out, out) is det.
+:- pred get_var_insts_and_lives(list(prog_var)::in, mode_info::in,
+	list(inst)::out, list(is_live)::out) is det.
 
 get_var_insts_and_lives([], _, [], []).
 get_var_insts_and_lives([Var | Vars], ModeInfo,
@@ -576,8 +552,8 @@
 	mode_list_get_initial_insts(OtherProcArgModes, ModuleInfo,
 							OtherInitialInsts),
 	pred_info_arg_types(PredInfo, ArgTypes),
-	compare_inst_list(InitialInsts, OtherInitialInsts, no,
-		ArgTypes, CompareInsts, ModuleInfo),
+	compare_inst_list(ModuleInfo, InitialInsts, OtherInitialInsts, no,
+		ArgTypes, CompareInsts),
 	CompareInsts = same,
 
 	%
@@ -625,8 +601,8 @@
 	mode_list_get_initial_insts(OtherProcArgModes, ModuleInfo,
 							OtherInitialInsts),
 	pred_info_arg_types(PredInfo, ArgTypes),
-	compare_inst_list(InitialInsts, OtherInitialInsts, no,
-		ArgTypes, CompareInitialInsts, ModuleInfo),
+	compare_inst_list(ModuleInfo, InitialInsts, OtherInitialInsts, no,
+		ArgTypes, CompareInitialInsts),
 	CompareInitialInsts = same,
 
 	%
@@ -635,8 +611,8 @@
 	mode_list_get_final_insts(ProcArgModes, ModuleInfo, FinalInsts),
 	mode_list_get_final_insts(OtherProcArgModes, ModuleInfo,
 							OtherFinalInsts),
-	compare_inst_list(FinalInsts, OtherFinalInsts, no,
-		ArgTypes, CompareFinalInsts, ModuleInfo),
+	compare_inst_list(ModuleInfo, FinalInsts, OtherFinalInsts, no,
+		ArgTypes, CompareFinalInsts),
 	CompareFinalInsts = same,
 
 	%
@@ -662,37 +638,35 @@
 
 %-----------------------------------------------------------------------------%
 
-/*
-The algorithm for choose_best_match is supposed to be equivalent
-to the following specification:
-
-	1.  Remove any modes that are strictly less instantiated or
-	    less informative on input than other valid modes; eg,
-	    prefer an (in, in, out) mode over an (out, in, out) mode,
-	    but not necessarily over an (out, out, in) mode,
-	    and prefer a (ground -> ...) mode over a (any -> ...) mode,
-	    and prefer a (bound(f) -> ...) mode over a (ground -> ...) mode,
-	    and prefer a (... -> dead) mode over a (... -> not dead) mode.
-
-	    Also prefer a (any -> ...) mode over a (free -> ...) mode,
-	    unless the actual argument is free, in which case prefer
-	    the (free -> ...) mode.
-
- 	2.  If neither is prefered over the other by step 1, then
-	    prioritize them by determinism, according to the standard
-	    partial order (best first):
-
- 				erroneous
- 			       /       \
-  			    det		failure
- 		          /    \       /
-  		      multi	semidet
-		         \      /
- 			  nondet
-
- 	3.  If there are still multiple possibilities, take them in 
- 	    declaration order.
-*/
+% The algorithm for choose_best_match is supposed to be equivalent
+% to the following specification:
+%
+% 	1.  Remove any modes that are strictly less instantiated or
+% 	    less informative on input than other valid modes; eg,
+% 	    prefer an (in, in, out) mode over an (out, in, out) mode,
+% 	    but not necessarily over an (out, out, in) mode,
+% 	    and prefer a (ground -> ...) mode over a (any -> ...) mode,
+% 	    and prefer a (bound(f) -> ...) mode over a (ground -> ...) mode,
+% 	    and prefer a (... -> dead) mode over a (... -> not dead) mode.
+%
+% 	    Also prefer a (any -> ...) mode over a (free -> ...) mode,
+% 	    unless the actual argument is free, in which case prefer
+% 	    the (free -> ...) mode.
+%
+%  	2.  If neither is prefered over the other by step 1, then
+% 	    prioritize them by determinism, according to the standard
+% 	    partial order (best first):
+%
+%  				erroneous
+%  			       /       \
+%   			    det		failure
+%  		          /    \       /
+%   		      multi	semidet
+% 		         \      /
+%  			  nondet
+%
+%  	3.  If there are still multiple possibilities, take them in
+%  	    declaration order.
 
 :- type match
 	--->	better
@@ -700,32 +674,31 @@
 	;	same
 	;	incomparable.
 
-:- pred choose_best_match(list(proc_mode), pred_id,
-		proc_table, list(prog_var), proc_id, inst_var_sub, list(mode),
-		mode_info).
-:- mode choose_best_match(in, in, in, in, out, out, out, in) is det.
+:- pred choose_best_match(mode_info::in, list(proc_mode)::in, pred_id::in,
+	proc_table::in, list(prog_var)::in, proc_id::out, inst_var_sub::out,
+	list(mode)::out) is det.
 
-choose_best_match([], _, _, _, _, _, _, _) :-
+choose_best_match(_, [], _, _, _, _, _, _) :-
 	error("choose_best_match: no best match").
-choose_best_match([proc_mode(ProcId, InstVarSub, ArgModes) | ProcIds], PredId,
-		Procs, ArgVars, TheProcId, TheInstVarSub, TheArgModes,
-		ModeInfo) :-
+choose_best_match(ModeInfo,
+		[proc_mode(ProcId, InstVarSub, ArgModes) | ProcIds], PredId,
+		Procs, ArgVars, TheProcId, TheInstVarSub, TheArgModes) :-
 	%
 	% This ProcId is best iff there is no other proc_id which is better.
 	%
 	(
 		\+ (
 			list__member(proc_mode(OtherProcId, _, _), ProcIds),
-			compare_proc(OtherProcId, ProcId, ArgVars, better,
-					Procs, ModeInfo)
+			compare_proc(ModeInfo, OtherProcId, ProcId, ArgVars,
+				Procs, better)
 		)
 	->
 		TheProcId = ProcId,
 		TheInstVarSub = InstVarSub,
 		TheArgModes = ArgModes
 	;
-		choose_best_match(ProcIds, PredId, Procs, ArgVars, TheProcId,
-			TheInstVarSub, TheArgModes, ModeInfo)
+		choose_best_match(ModeInfo, ProcIds, PredId, Procs, ArgVars,
+			TheProcId, TheInstVarSub, TheArgModes)
 	).
 
 	%
@@ -737,11 +710,10 @@
 	% modes_are_indistinguishable/4 and
 	% modes_are_identical_bar_cc/4 above.
 	%
-:- pred compare_proc(proc_id, proc_id, list(prog_var), match, proc_table,
-		mode_info).
-:- mode compare_proc(in, in, in, out, in, in) is det.
+:- pred compare_proc(mode_info::in, proc_id::in, proc_id::in,
+	list(prog_var)::in, proc_table::in, match::out) is det.
 
-compare_proc(ProcId, OtherProcId, ArgVars, Compare, Procs, ModeInfo) :-
+compare_proc(ModeInfo, ProcId, OtherProcId, ArgVars, Procs, Compare) :-
 	map__lookup(Procs, ProcId, ProcInfo),
 	map__lookup(Procs, OtherProcId, OtherProcInfo),
 	%
@@ -756,8 +728,8 @@
 	mode_list_get_initial_insts(OtherProcArgModes, ModuleInfo,
 							OtherInitialInsts),
 	get_var_insts_and_lives(ArgVars, ModeInfo, ArgInitialInsts, _ArgLives),
-	compare_inst_list(InitialInsts, OtherInitialInsts, yes(ArgInitialInsts),
-		ArgTypes, CompareInsts, ModuleInfo),
+	compare_inst_list(ModuleInfo, InitialInsts, OtherInitialInsts,
+		yes(ArgInitialInsts), ArgTypes, CompareInsts),
 	%
 	% Compare the expected livenesses of the arguments
 	%
@@ -781,39 +753,37 @@
 	combine_results(CompareInsts, CompareLives, Compare0),
 	prioritized_combine_results(Compare0, CompareDet, Compare).
 
-:- pred compare_inst_list(list(inst), list(inst), maybe(list(inst)),
-		list(type), match, module_info).
-:- mode compare_inst_list(in, in, in, in, out, in) is det.
+:- pred compare_inst_list(module_info::in, list(inst)::in, list(inst)::in,
+	maybe(list(inst))::in, list(type)::in, match::out) is det.
 
-compare_inst_list(InstsA, InstsB, ArgInsts, Types, Result, ModuleInfo) :-
+compare_inst_list(ModuleInfo, InstsA, InstsB, ArgInsts, Types, Result) :-
 	(
-		compare_inst_list_2(InstsA, InstsB, ArgInsts, Types, Result0,
-			ModuleInfo)
+		compare_inst_list_2(ModuleInfo, InstsA, InstsB, ArgInsts,
+			Types, Result0)
 	->
 		Result = Result0
 	;
 		error("compare_inst_list: length mis-match")
 	).
 
-:- pred compare_inst_list_2(list(inst), list(inst), maybe(list(inst)),
-		list(type), match, module_info).
-:- mode compare_inst_list_2(in, in, in, in, out, in) is semidet.
-
-compare_inst_list_2([], [], _, [], same, _).
-compare_inst_list_2([InstA | InstsA], [InstB | InstsB],
-		no, [Type | Types], Result, ModuleInfo) :-
-	compare_inst(InstA, InstB, no, Type, Result0, ModuleInfo),
-	compare_inst_list_2(InstsA, InstsB, no, Types, Result1, ModuleInfo),
+:- pred compare_inst_list_2(module_info::in, list(inst)::in, list(inst)::in,
+	maybe(list(inst))::in, list(type)::in, match::out) is semidet.
+
+compare_inst_list_2(_, [], [], _, [], same).
+compare_inst_list_2(ModuleInfo, [InstA | InstsA], [InstB | InstsB],
+		no, [Type | Types], Result) :-
+	compare_inst(ModuleInfo, InstA, InstB, no, Type, Result0),
+	compare_inst_list_2(ModuleInfo, InstsA, InstsB, no, Types, Result1),
 	combine_results(Result0, Result1, Result).
-compare_inst_list_2([InstA | InstsA], [InstB | InstsB],
-		yes([ArgInst|ArgInsts]), [Type | Types], Result, ModuleInfo) :-
-	compare_inst(InstA, InstB, yes(ArgInst), Type, Result0, ModuleInfo),
-	compare_inst_list_2(InstsA, InstsB, yes(ArgInsts), Types, Result1,
-		ModuleInfo),
+compare_inst_list_2(ModuleInfo, [InstA | InstsA], [InstB | InstsB],
+		yes([ArgInst|ArgInsts]), [Type | Types], Result) :-
+	compare_inst(ModuleInfo, InstA, InstB, yes(ArgInst), Type, Result0),
+	compare_inst_list_2(ModuleInfo, InstsA, InstsB, yes(ArgInsts), Types,
+		Result1),
 	combine_results(Result0, Result1, Result).
 
-:- pred compare_liveness_list(list(is_live), list(is_live), match).
-:- mode compare_liveness_list(in, in, out) is det.
+:- pred compare_liveness_list(list(is_live)::in, list(is_live)::in, match::out)
+	is det.
 
 compare_liveness_list([], [], same).
 compare_liveness_list([_|_], [], _) :-
@@ -831,8 +801,7 @@
 	%	must be dead, so prefer the mode which can take advantage
 	%	of that).
 	%
-:- pred compare_liveness(is_live, is_live, match).
-:- mode compare_liveness(in, in, out) is det.
+:- pred compare_liveness(is_live::in, is_live::in, match::out) is det.
 
 compare_liveness(dead, dead, same).
 compare_liveness(dead, live, better).
@@ -842,8 +811,7 @@
 	%
 	% combine two results, giving priority to the first one
 	%
-:- pred prioritized_combine_results(match, match, match).
-:- mode prioritized_combine_results(in, in, out) is det.
+:- pred prioritized_combine_results(match::in, match::in, match::out) is det.
 
 prioritized_combine_results(better, _, better).
 prioritized_combine_results(worse, _, worse).
@@ -853,8 +821,7 @@
 	%
 	% combine two results, giving them equal priority
 	%
-:- pred combine_results(match, match, match).
-:- mode combine_results(in, in, out) is det.
+:- pred combine_results(match::in, match::in, match::out) is det.
 
 combine_results(better, better, better).
 combine_results(better, same, better).
@@ -884,10 +851,10 @@
 	% 	prefer ground to any	(e.g. prefer in to in(any))
 	% 	prefer any to free	(e.g. prefer any->ground to out)
 
-:- pred compare_inst(inst, inst, maybe(inst), type, match, module_info).
-:- mode compare_inst(in, in, in, in, out, in) is det.
+:- pred compare_inst(module_info::in, (inst)::in, (inst)::in, maybe(inst)::in,
+	(type)::in, match::out) is det.
 
-compare_inst(InstA, InstB, MaybeArgInst, Type, Result, ModuleInfo) :-
+compare_inst(ModuleInfo, InstA, InstB, MaybeArgInst, Type, Result) :-
 	% inst_matches_initial(A,B) succeeds iff
 	%	A specifies at least as much information
 	%	and at least as much binding as B --
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.66
diff -u -b -r1.66 modecheck_unify.m
--- compiler/modecheck_unify.m	6 Nov 2003 03:42:35 -0000	1.66
+++ compiler/modecheck_unify.m	28 Mar 2004 19:07:43 -0000
@@ -1239,8 +1239,8 @@
 %       and the initial insts of the functor arguments,
 %       compute the modes of the functor arguments
 
-:- pred get_mode_of_args(inst, list(inst), list(mode)).
-:- mode get_mode_of_args(in, in, out) is semidet.
+:- pred get_mode_of_args((inst)::in, list(inst)::in, list(mode)::out)
+	is semidet.
 
 get_mode_of_args(not_reached, ArgInsts, ArgModes) :-
 	mode_set_args(ArgInsts, not_reached, ArgModes).
@@ -1259,16 +1259,15 @@
 get_mode_of_args(constrained_inst_vars(_, Inst), ArgInsts, ArgModes) :-
 	get_mode_of_args(Inst, ArgInsts, ArgModes).
 
-:- pred get_mode_of_args_2(list(inst), list(inst), list(mode)).
-:- mode get_mode_of_args_2(in, in, out) is semidet.
+:- pred get_mode_of_args_2(list(inst)::in, list(inst)::in, list(mode)::out)
+	is semidet.
 
 get_mode_of_args_2([], [], []).
 get_mode_of_args_2([InstA | InstsA], [InstB | InstsB], [Mode | Modes]) :-
 	Mode = (InstA -> InstB),
 	get_mode_of_args_2(InstsA, InstsB, Modes).
 
-:- pred mode_set_args(list(inst), inst, list(mode)).
-:- mode mode_set_args(in, in, out) is det.
+:- pred mode_set_args(list(inst)::in, (inst)::in, list(mode)::out) is det.
 
 mode_set_args([], _, []).
 mode_set_args([Inst | Insts], FinalInst, [Mode | Modes]) :-
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.275
diff -u -b -r1.275 modes.m
--- compiler/modes.m	6 Nov 2003 03:42:35 -0000	1.275
+++ compiler/modes.m	28 Mar 2004 19:15:18 -0000
@@ -1159,13 +1159,13 @@
 
 	mode_info_get_instmap(!.ModeInfo, InstMap0),
 	DeterminismKnown = no,
-	modecheck_call_pred(PredId, ProcId0, Args0, DeterminismKnown,
-		Mode, Args, ExtraGoals, !ModeInfo),
+	modecheck_call_pred(PredId, DeterminismKnown, ProcId0, ProcId,
+		Args0, Args, ExtraGoals, !ModeInfo),
 
 	mode_info_get_module_info(!.ModeInfo, ModuleInfo),
 	mode_info_get_predid(!.ModeInfo, CallerPredId),
-	Builtin = builtin_state(ModuleInfo, CallerPredId, PredId, Mode),
-	Call = call(PredId, Mode, Args, Builtin, Context, PredName),
+	Builtin = builtin_state(ModuleInfo, CallerPredId, PredId, ProcId),
+	Call = call(PredId, ProcId, Args, Builtin, Context, PredName),
 	handle_extra_goals(Call, ExtraGoals, GoalInfo0, Args0, Args,
 		InstMap0, Goal, !ModeInfo, !IO),
 
@@ -1182,7 +1182,7 @@
 	(
 		GenericCall = higher_order(PredVar, _, PredOrFunc, _),
 		modecheck_higher_order_call(PredOrFunc, PredVar,
-			Args0, Modes, Det, Args, ExtraGoals, !ModeInfo),
+			Args0, Args, Modes, Det, ExtraGoals, !ModeInfo),
 		AllArgs0 = [PredVar | Args0],
 		AllArgs = [PredVar | Args]
 	;
@@ -1193,15 +1193,15 @@
 		error("modecheck_goal_expr: class_method_call")
 	;
 		GenericCall = unsafe_cast,
-		modecheck_builtin_cast(Args0, Modes0, Det, Args, ExtraGoals,
+		modecheck_builtin_cast(Modes0, Args0, Args, Det, ExtraGoals,
 			!ModeInfo),
 		Modes = Modes0,
 		AllArgs0 = Args0,
 		AllArgs = Args
 	;
 		GenericCall = aditi_builtin(AditiBuiltin, UpdatedCallId),
-		modecheck_aditi_builtin(AditiBuiltin, UpdatedCallId,
-			Args0, Modes0, Det, Args, ExtraGoals, !ModeInfo),
+		modecheck_aditi_builtin(AditiBuiltin, UpdatedCallId, Modes0,
+			Args0, Args, Det, ExtraGoals, !ModeInfo),
 		Modes = Modes0,
 		AllArgs0 = Args0,
 		AllArgs = Args
@@ -1248,8 +1248,8 @@
 	mode_info_get_instmap(!.ModeInfo, InstMap0),
 	DeterminismKnown = no,
 	mode_info_set_call_context(call(call(CallId)), !ModeInfo),
-	modecheck_call_pred(PredId, ProcId0, Args0, DeterminismKnown,
-		ProcId, Args, ExtraGoals, !ModeInfo),
+	modecheck_call_pred(PredId, DeterminismKnown, ProcId0, ProcId,
+		Args0, Args, ExtraGoals, !ModeInfo),
 
 	Pragma = foreign_proc(Attributes, PredId, ProcId, Args0, ArgNameMap,
 		OrigArgTypes, PragmaCode),
Index: compiler/prog_data.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_data.m,v
retrieving revision 1.106
diff -u -b -r1.106 prog_data.m
--- compiler/prog_data.m	23 Mar 2004 10:52:11 -0000	1.106
+++ compiler/prog_data.m	23 Mar 2004 13:02:10 -0000
@@ -521,8 +521,7 @@
 :- type foreign_language_type
 	--->	il(il_foreign_type)
 	;	c(c_foreign_type)
-	;	java(java_foreign_type)
-	.
+	;	java(java_foreign_type).
 
 :- type il_foreign_type
 	--->	il(
@@ -738,14 +737,19 @@
 	% (This invariant now applies to all types, but is
 	% especially important here.)
 :- type class_constraint
-	---> constraint(class_name, list(type)).
+	--->	constraint(
+			class_name,
+			list(type)
+		).
 
 :- type class_constraints
 	---> constraints(
 		univ_constraints	:: list(class_constraint),
-					% universally quantified constraints
+						% universally quantified
+						% constraints
 		exist_constraints	:: list(class_constraint)
-					% existentially quantified constraints
+						% existentially quantified
+						% constraints
 	).
 
 :- type class_name == sym_name.
@@ -765,46 +769,64 @@
 		% a predicate or function method.  Such declarations
 		% specify the type of the predicate or function,
 		% and may optionally also specify the mode and determinism.
-	--->	pred_or_func(tvarset, inst_varset, existq_tvars, pred_or_func,
-			sym_name, list(type_and_mode), maybe(type),
-			maybe(inst), maybe(determinism),
-			condition, purity, class_constraints, prog_context)
-		%       TypeVarNames, InstVarNames,
-		%	ExistentiallyQuantifiedTypeVars,
-		%	PredOrFunc, PredName, ArgTypes, WithType, Determinism,
-		%	Cond, Purity, ClassContext, Context
+	--->	pred_or_func(
+			tvarset,		% type variables
+			inst_varset,		% inst variables
+			existq_tvars,		% existentially quantified
+						% type variables
+			pred_or_func,
+			sym_name,		% name of the pred or func
+			list(type_and_mode),	% the arguments' types and
+						% modes
+			maybe(type),		% any `with_type` annotation
+			maybe(inst),		% any `with_inst` annotation
+			maybe(determinism),	% any determinism declaration
+			condition,		% any attached declaration
+			purity,			% any purity annotation
+			class_constraints,	% the typeclass constraints on
+						% the declaration
+			prog_context		% the declaration's context
+		)
 
 		% pred_or_func_mode(...) here represents a `mode ...'
 		% declaration in a type class body.  Such a declaration
 		% declares a mode for one of the type class methods.
-	; 	pred_or_func_mode(inst_varset, maybe(pred_or_func), sym_name,
-			list(mode), maybe(inst), maybe(determinism),
-			condition, prog_context)
-		%       InstVarNames, MaybePredOrFunc, PredName, ArgModes,
-		%	Determinism, WithInst, Cond
-		%	Context
-		%
-		% 	For mode declarations using `with_inst` we don't
-		%	know whether it's a predicate or function until
-		%	we've expanded the inst.
-	.
+	; 	pred_or_func_mode(
+			inst_varset,		% inst variables
+			maybe(pred_or_func),	% whether the method is a pred
+						% or a func; for declarations
+						% using `with_inst`, we don't
+						% know which until we've
+						% expanded the inst.
+			sym_name,		% the method name
+			list(mode),		% the arguments' modes
+			maybe(inst),		% any `with_inst` annotation
+			maybe(determinism),	% any determinism declaration
+			condition,		% any attached condition
+			prog_context		% the declaration's context
+		).
 
 :- type instance_method
-	--->	instance_method(pred_or_func, sym_name, instance_proc_def,
-			arity, prog_context).
-				% PredOrFunc, Method, Instance, Arity,
-				% Line number of declaration
+	--->	instance_method(
+			pred_or_func,
+			sym_name,		% method name
+			instance_proc_def,
+			arity,
+			prog_context		% context of the instance
+						% declaration
+		).
 
 :- type instance_proc_def
 		% defined using the `pred(...) is <Name>' syntax
-	--->	name(sym_name)
+	--->	name(
+			sym_name
+		)
 
 		% defined using clauses
 	;	clauses(
 			list(item)	% the items must be either
 					% pred_clause or func_clause items
-		)
-	.
+		).
 
 :- type instance_body
 	--->	abstract
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.79
diff -u -b -r1.79 unique_modes.m
--- compiler/unique_modes.m	1 Dec 2003 15:55:54 -0000	1.79
+++ compiler/unique_modes.m	28 Mar 2004 19:11:37 -0000
@@ -598,8 +598,8 @@
 		%
 		mode_info_set_instmap(InstMap0, !ModeInfo),
 		proc_info_inferred_determinism(ProcInfo, Determinism),
-		modecheck_call_pred(PredId, ProcId0, ArgVars, yes(Determinism),
-			ProcId, NewArgVars, ExtraGoals, !ModeInfo),
+		modecheck_call_pred(PredId, yes(Determinism), ProcId0, ProcId,
+			ArgVars, NewArgVars, ExtraGoals, !ModeInfo),
 		
 		( NewArgVars = ArgVars, ExtraGoals = no_extra_goals ->
 			true
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list