[m-rev.] for review: improve variable naming in the debugger

Simon Taylor stayl at cs.mu.OZ.AU
Thu Jun 6 01:36:31 AEST 2002


Estimated hours taken: 10
Branches: main

Improve variable naming in the debugger. Where possible, use
the user's argument names rather than `HeadVar__N'.

compiler/clause_to_proc.m:
	Use the user's names for the arguments of
	`:- pragma foreign_proc' procedures.

compiler/simplify.m:
	When performing excess assignment elimination with `--trace deep',
	don't replace a variable with a meaningful name with `HeadVar__N'
	or an unnamed variable.

compiler/trace_params.m:
	Add a predicate `trace_level_needs_meaningful_var_names'
	for use by simplify.m.

compiler/typecheck.m:
	For predicates with a single clause, attempt to replace the
	`HeadVar__N' variables with the user's original head variables.

trace/mercury_trace_declarative.c:
trace/mercury_trace_vars.c:
	Don't assume head variables have names of the form `HeadVar__N'.

	Print the argument number when printing the names of
	head variables.

tests/debugger/browser_test.inp:
tests/debugger/completion.inp:
	Change names of variables in `print' commands.

tests/debugger/*.exp:
tests/debugger/*.exp2:
tests/debugger/declarative/dependency.exp:
tests/invalid/aditi_errors.err_exp:
tests/invalid/mode_inf.err_exp:
tests/invalid/record_syntax_errors.err_exp:
	Update expected output.

Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.33
diff -u -u -r1.33 clause_to_proc.m
--- compiler/clause_to_proc.m	28 Mar 2002 03:42:43 -0000	1.33
+++ compiler/clause_to_proc.m	5 Jun 2002 08:37:03 -0000
@@ -51,7 +51,7 @@
 :- import_module hlds__hlds_goal, hlds__hlds_data, parse_tree__prog_data.
 :- import_module check_hlds__mode_util, hlds__make_hlds, check_hlds__purity.
 :- import_module libs__globals.
-:- import_module bool, int, set, map, varset.
+:- import_module assoc_list, bool, int, set, map, varset.
 
 maybe_add_default_func_modes([], Preds, Preds).
 maybe_add_default_func_modes([PredId | PredIds], Preds0, Preds) :-
@@ -143,13 +143,40 @@
 	copy_clauses_to_procs_2(ProcIds, ClausesInfo, Procs1, Procs).
 
 copy_clauses_to_proc(ProcId, ClausesInfo, Proc0, Proc) :-
-	ClausesInfo = clauses_info(VarSet, _, _, VarTypes, HeadVars, Clauses,
+	ClausesInfo = clauses_info(VarSet0, _, _, VarTypes, HeadVars, Clauses,
 		TI_VarMap, TCI_VarMap, _),
 	select_matching_clauses(Clauses, ProcId, MatchingClauses),
 	get_clause_goals(MatchingClauses, GoalList),
 	( GoalList = [SingleGoal] ->
+		(
+			SingleGoal = foreign_proc(_, _, _, Args,
+					ArgNames, _, _) - _
+		->
+			%
+			% Use the original variable names for the headvars
+			% of foreign_proc clauses, not the introduced
+			% `HeadVar__n' names.
+			%
+			ArgsAndNames = assoc_list__from_corresponding_lists(
+					Args, ArgNames),
+			VarSet = list__foldl(
+			    (func(Arg - MaybeArgName, Vars0) = Vars :-
+				(
+				    MaybeArgName = yes(ArgName - _),
+				    varset__name_var(Vars0, Arg, ArgName, Vars)
+				;
+				    MaybeArgName = no,
+				    Vars = Vars0
+				)
+			    ),
+			    ArgsAndNames, VarSet0)
+		;
+			VarSet = VarSet0
+		),
 		Goal = SingleGoal
 	;
+		VarSet = VarSet0,
+
 		%
 		% Convert the list of clauses into a disjunction,
 		% and construct a goal_info for the disjunction.
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.103
diff -u -u -r1.103 simplify.m
--- compiler/simplify.m	14 May 2002 14:34:28 -0000	1.103
+++ compiler/simplify.m	4 Jun 2002 17:34:55 -0000
@@ -88,9 +88,9 @@
 :- import_module transform_hlds__const_prop.
 :- import_module transform_hlds__pd_cost.
 :- import_module ll_backend__code_util, ll_backend__follow_code.
-:- import_module libs__options.
+:- import_module libs__options, libs__trace_params.
 
-:- import_module int, set, require, std_util, varset, term.
+:- import_module int, set, require, std_util, string, varset, term.
 
 %-----------------------------------------------------------------------------%
 
@@ -1680,7 +1680,14 @@
 	( simplify_do_excess_assigns(Info0) ->
 		goal_info_get_nonlocals(ConjInfo, ConjNonLocals),
 		map__init(Subn0),
-		simplify__find_excess_assigns_in_conj(ConjNonLocals,
+		simplify_info_get_module_info(Info0, ModuleInfo),
+		module_info_globals(ModuleInfo, Globals),
+		globals__get_trace_level(Globals, TraceLevel),
+		globals__lookup_bool_option(Globals,
+			trace_optimized, TraceOptimized),
+		simplify_info_get_varset(Info0, VarSet0),
+		simplify__find_excess_assigns_in_conj(TraceLevel,
+			TraceOptimized, VarSet0, ConjNonLocals,
 			Goals0, [], RevGoals, Subn0, Subn1),
 		( map__is_empty(Subn1) ->
 			Goals = Goals0,
@@ -1691,7 +1698,6 @@
 			MustSub = no,
 			goal_util__rename_vars_in_goals(Goals1, MustSub,
 				Subn, Goals),
-			simplify_info_get_varset(Info0, VarSet0),
 			map__keys(Subn0, RemovedVars),
 			varset__delete_vars(VarSet0, RemovedVars, VarSet),
 			simplify_info_set_varset(Info0, VarSet, Info1),
@@ -1714,28 +1720,35 @@
 
 :- type var_renaming == map(prog_var, prog_var).
 
-:- pred simplify__find_excess_assigns_in_conj(set(prog_var)::in,
-	list(hlds_goal)::in, list(hlds_goal)::in, list(hlds_goal)::out,
+:- pred simplify__find_excess_assigns_in_conj(trace_level::in, bool::in,
+	prog_varset::in, set(prog_var)::in, list(hlds_goal)::in,
+	list(hlds_goal)::in, list(hlds_goal)::out,
 	var_renaming::in, var_renaming::out) is det.
 
-simplify__find_excess_assigns_in_conj(_, [], RevGoals, RevGoals,
+simplify__find_excess_assigns_in_conj(_, _, _, _, [], RevGoals, RevGoals,
 			Subn, Subn).
-simplify__find_excess_assigns_in_conj(ConjNonLocals, [Goal | Goals],
-			RevGoals0, RevGoals, Subn0, Subn) :-
-	( goal_is_excess_assign(ConjNonLocals, Goal, Subn0, Subn1) ->
+simplify__find_excess_assigns_in_conj(Trace, TraceOptimized, VarSet,
+		ConjNonLocals, [Goal | Goals], RevGoals0, RevGoals,
+		Subn0, Subn) :-
+	(
+		goal_is_excess_assign(Trace, TraceOptimized,
+			VarSet, ConjNonLocals, Goal, Subn0, Subn1)
+	->
 		RevGoals1 = RevGoals0,
 		Subn2 = Subn1
 	;
 		RevGoals1 = [Goal | RevGoals0],
 		Subn2 = Subn0
 	),
-	simplify__find_excess_assigns_in_conj(ConjNonLocals, Goals,
-		RevGoals1, RevGoals, Subn2, Subn).
+	simplify__find_excess_assigns_in_conj(Trace, TraceOptimized, VarSet,
+		ConjNonLocals, Goals, RevGoals1, RevGoals, Subn2, Subn).
 
-:- pred goal_is_excess_assign(set(prog_var)::in, hlds_goal::in,
-	var_renaming::in, var_renaming::out) is semidet.
+:- pred goal_is_excess_assign(trace_level::in, bool::in, prog_varset::in,
+	set(prog_var)::in, hlds_goal::in, var_renaming::in,
+	var_renaming::out) is semidet.
 
-goal_is_excess_assign(ConjNonLocals, Goal0, Subn0, Subn) :-
+goal_is_excess_assign(Trace, TraceOptimized, VarSet, ConjNonLocals,
+		Goal0, Subn0, Subn) :-
 	Goal0 = unify(_, _, _, Unif, _) - _,
 	Unif = assign(LeftVar0, RightVar0),
 
@@ -1745,12 +1758,47 @@
 	%
 	find_renamed_var(Subn0, LeftVar0, LeftVar),
 	find_renamed_var(Subn0, RightVar0, RightVar),
-	( \+ set__member(LeftVar, ConjNonLocals) ->
-		map__det_insert(Subn0, LeftVar, RightVar, Subn)
-	; \+ set__member(RightVar, ConjNonLocals) ->
-		map__det_insert(Subn0, RightVar, LeftVar, Subn)
+
+	CanElimLeft = ( set__member(LeftVar, ConjNonLocals) -> no ; yes ),
+	CanElimRight = ( set__member(RightVar, ConjNonLocals) -> no ; yes ),
+
+	% If we have a choice, eliminate an unnamed variable.
+	( CanElimLeft = yes, CanElimRight = yes ->
+		( var_is_named(VarSet, LeftVar) ->
+			ElimVar = RightVar,
+			ReplacementVar = LeftVar
+		;
+			ElimVar = LeftVar,
+			ReplacementVar = RightVar
+		)
+	; CanElimLeft = yes ->
+		ElimVar = LeftVar,
+		ReplacementVar = RightVar
+	; CanElimRight = yes ->
+		ElimVar = RightVar,
+		ReplacementVar = LeftVar
 	;
 		fail
+	),
+	map__det_insert(Subn0, ElimVar, ReplacementVar, Subn),
+
+	% If the module is being compiled with `--trace deep' and
+	% `--no-trace-optimized' don't replace a meaningful variable
+	% name with `HeadVar__n' or an anonymous variable.
+	\+ (
+		trace_level_needs_meaningful_var_names(Trace) = yes,
+		TraceOptimized = no,
+		var_is_named(VarSet, ElimVar),
+		\+ var_is_named(VarSet, ReplacementVar)
+	).
+
+:- pred var_is_named(prog_varset::in, prog_var::in) is semidet.
+
+var_is_named(VarSet, Var) :-
+	varset__search_name(VarSet, Var, Name),
+	\+ (
+		string__append("HeadVar__", Suffix, Name),
+		string__to_int(Suffix, _)
 	).
 
 :- pred find_renamed_var(var_renaming, prog_var, prog_var).
Index: compiler/trace_params.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace_params.m,v
retrieving revision 1.8
diff -u -u -r1.8 trace_params.m
--- compiler/trace_params.m	16 May 2002 13:14:51 -0000	1.8
+++ compiler/trace_params.m	4 Jun 2002 10:36:10 -0000
@@ -40,6 +40,10 @@
 :- func trace_needs_proc_body_reps(trace_level, trace_suppress_items) = bool.
 :- func trace_needs_port(trace_level, trace_suppress_items, trace_port) = bool.
 
+	% Should optimization passes maintain meaningful
+	% variable names where possible.
+:- func trace_level_needs_meaningful_var_names(trace_level) = bool.
+
 :- func trace_level_none = trace_level.
 
 	% This is used to represent the trace level in the module layout.
@@ -104,6 +108,12 @@
 trace_level_allows_delay_death(deep) = yes.
 trace_level_allows_delay_death(decl) = yes.
 trace_level_allows_delay_death(decl_rep) = yes.
+
+trace_level_needs_meaningful_var_names(none) = no.
+trace_level_needs_meaningful_var_names(shallow) = no.
+trace_level_needs_meaningful_var_names(deep) = yes.
+trace_level_needs_meaningful_var_names(decl) = yes.
+trace_level_needs_meaningful_var_names(decl_rep) = yes.
 
 trace_needs_return_info(TraceLevel, TraceSuppressItems) = Need :-
 	(
Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.317
diff -u -u -r1.317 typecheck.m
--- compiler/typecheck.m	7 Apr 2002 10:22:51 -0000	1.317
+++ compiler/typecheck.m	4 Jun 2002 06:33:30 -0000
@@ -153,7 +153,7 @@
 
 :- implementation.
 
-:- import_module hlds__hlds_goal, parse_tree__prog_util.
+:- import_module hlds__hlds_goal, hlds__goal_util, parse_tree__prog_util.
 :- import_module check_hlds__type_util, parse_tree__modules.
 :- import_module ll_backend__code_util.
 :- import_module parse_tree__prog_io, parse_tree__prog_io_util.
@@ -188,20 +188,20 @@
 	{ module_info_predids(Module0, PredIds) },
 	globals__io_lookup_int_option(type_inference_iteration_limit,
 		MaxIterations),
-	typecheck_to_fixpoint(MaxIterations, PredIds, Module0,
+	typecheck_to_fixpoint(1, MaxIterations, PredIds, Module0,
 		Module, FoundError, ExceededIterationLimit),
 	write_inference_messages(PredIds, Module).
 
 	% Repeatedly typecheck the code for a group of predicates
 	% until a fixpoint is reached, or until some errors are detected.
 
-:- pred typecheck_to_fixpoint(int, list(pred_id), module_info, module_info, 
-		bool, bool, io__state, io__state).
-:- mode typecheck_to_fixpoint(in, in, in, out, out, out, di, uo) is det.
+:- pred typecheck_to_fixpoint(int, int, list(pred_id),
+		module_info, module_info, bool, bool, io__state, io__state).
+:- mode typecheck_to_fixpoint(in, in, in, in, out, out, out, di, uo) is det.
 
-typecheck_to_fixpoint(NumIterations, PredIds, Module0, Module,
+typecheck_to_fixpoint(Iteration, NumIterations, PredIds, Module0, Module,
 		FoundError, ExceededIterationLimit) -->
-	typecheck_pred_types_2(PredIds, Module0, Module1,
+	typecheck_pred_types_2(Iteration, PredIds, Module0, Module1,
 		no, FoundError1, no, Changed),
 	( { Changed = no ; FoundError1 = yes } ->
 		{ Module = Module1 },
@@ -214,10 +214,10 @@
 		;
 			[]
 		),
-		{ NumIterations1 = NumIterations - 1 },
-		( { NumIterations1 > 0 } ->
-			typecheck_to_fixpoint(NumIterations1, PredIds, Module1,
-				Module, FoundError, ExceededIterationLimit)
+		( { Iteration < NumIterations } ->
+			typecheck_to_fixpoint(Iteration + 1, NumIterations,
+				PredIds, Module1, Module,
+				FoundError, ExceededIterationLimit)
 		;
 			typecheck_report_max_iterations_exceeded,
 			{ Module = Module1 },
@@ -246,14 +246,14 @@
 
 	% Iterate over the list of pred_ids in a module.
 
-:- pred typecheck_pred_types_2(list(pred_id), module_info, module_info,
+:- pred typecheck_pred_types_2(int, list(pred_id), module_info, module_info,
 	bool, bool, bool, bool, io__state, io__state).
-:- mode typecheck_pred_types_2(in, in, out,
+:- mode typecheck_pred_types_2(in, in, in, out,
 	in, out, in, out, di, uo) is det.
 
-typecheck_pred_types_2([], ModuleInfo, ModuleInfo, 
+typecheck_pred_types_2(_, [], ModuleInfo, ModuleInfo, 
 		Error, Error, Changed, Changed) --> [].
-typecheck_pred_types_2([PredId | PredIds], ModuleInfo0, ModuleInfo, 
+typecheck_pred_types_2(Iteration, [PredId | PredIds], ModuleInfo0, ModuleInfo, 
 		Error0, Error, Changed0, Changed) -->
 	{ module_info_preds(ModuleInfo0, Preds0) },
 	{ map__lookup(Preds0, PredId, PredInfo0) },
@@ -264,7 +264,7 @@
 		{ ModuleInfo2 = ModuleInfo0 },
 		{ Changed2 = Changed0 }
 	;
-		typecheck_pred_type(PredId, PredInfo0, ModuleInfo0, 
+		typecheck_pred_type(Iteration, PredId, PredInfo0, ModuleInfo0, 
 			PredInfo1, Error1, Changed1),
 		(
 			{ Error1 = no },
@@ -304,15 +304,15 @@
 		{ bool__or(Error0, Error1, Error2) },
 		{ bool__or(Changed0, Changed1, Changed2) }
 	),
-	typecheck_pred_types_2(PredIds, ModuleInfo2, ModuleInfo, 
+	typecheck_pred_types_2(Iteration, PredIds, ModuleInfo2, ModuleInfo, 
 		Error2, Error, Changed2, Changed).
 
-:- pred typecheck_pred_type(pred_id, pred_info, module_info,
+:- pred typecheck_pred_type(int, pred_id, pred_info, module_info,
 		pred_info, bool, bool, io__state, io__state).
-:- mode typecheck_pred_type(in, in, in, out, out, out, di, uo) is det.
+:- mode typecheck_pred_type(in, in, in, in, out, out, out, di, uo) is det.
 
-typecheck_pred_type(PredId, PredInfo0, ModuleInfo, PredInfo, Error, Changed,
-		IOState0, IOState) :-
+typecheck_pred_type(Iteration, PredId, PredInfo0, ModuleInfo, PredInfo,
+		Error, Changed, IOState0, IOState) :-
 	(
 	    % Compiler-generated predicates are created already type-correct,
 	    % there's no need to typecheck them.  Same for builtins.
@@ -335,8 +335,15 @@
 	    Changed = no,
 	    IOState = IOState0
 	;
-	    maybe_add_field_access_function_clause(ModuleInfo,
-		    PredInfo0, PredInfo1),
+	    globals__io_get_globals(Globals, IOState0, IOState1),
+	    ( Iteration = 1 ->
+		maybe_add_field_access_function_clause(ModuleInfo,
+			PredInfo0, PredInfo0a),
+		maybe_improve_single_clause_headvar_names(Globals,
+			PredInfo0a, PredInfo1)
+	    ;
+		PredInfo1 = PredInfo0	
+	    ),
 	    pred_info_arg_types(PredInfo1, _ArgTypeVarSet, ExistQVars0,
 		    ArgTypes0),
 	    pred_info_clauses_info(PredInfo1, ClausesInfo0),
@@ -352,7 +359,7 @@
 			% in polymorphism__expand_class_method_bodies
 	        pred_info_get_markers(PredInfo1, Markers),
 		( check_marker(Markers, class_method) ->
-			IOState = IOState0,
+			IOState = IOState1,
 				% For the moment, we just insert the types
 				% of the head vars into the clauses_info
 			map__from_corresponding_lists(HeadVars, ArgTypes0,
@@ -373,7 +380,7 @@
 			Changed = no
 		;
 			report_error_no_clauses(PredId, PredInfo1, ModuleInfo,
-			    IOState0, IOState),
+			    IOState1, IOState),
 			PredInfo = PredInfo1,
 			Error = yes,
 			Changed = no
@@ -391,13 +398,13 @@
 			% `pred foo(T1, T2, ..., TN)' by make_hlds.m.
 			Inferring = yes,
 			write_pred_progress_message("% Inferring type of ",
-				PredId, ModuleInfo, IOState0, IOState1),
+				PredId, ModuleInfo, IOState1, IOState2),
 			HeadTypeParams1 = [],
 			PredConstraints = constraints([], [])
 		;
 			Inferring = no,
 			write_pred_progress_message("% Type-checking ",
-				PredId, ModuleInfo, IOState0, IOState1),
+				PredId, ModuleInfo, IOState1, IOState2),
 			term__vars_list(ArgTypes0, HeadTypeParams0),
 			list__delete_elems(HeadTypeParams0, ExistQVars0,
 				HeadTypeParams1),
@@ -419,7 +426,7 @@
 		;
 			IsFieldAccessFunction = no
 		),
-		typecheck_info_init(IOState1, ModuleInfo, PredId,
+		typecheck_info_init(IOState2, ModuleInfo, PredId,
 				IsFieldAccessFunction, TypeVarSet0, VarSet,
 				ExplicitVarTypes0, HeadTypeParams1,
 				Constraints, Status, TypeCheckInfo1),
@@ -829,6 +836,130 @@
 		PredInfo = PredInfo0
 	).
 
+	% If there is only one clause, use the original head variables
+	% from the clause rather than the introduced `HeadVar__n' variables
+	% as the head variables in the proc_info.
+	% This gives better error messages, more meaningful variable
+	% names in the debugger and slightly faster compilation.
+:- pred maybe_improve_single_clause_headvar_names(globals,
+		pred_info, pred_info).
+:- mode maybe_improve_single_clause_headvar_names(in, in, out) is det.
+
+maybe_improve_single_clause_headvar_names(Globals, PredInfo0, PredInfo) :-
+	pred_info_clauses_info(PredInfo0, ClausesInfo0),
+	clauses_info_clauses(ClausesInfo0, Clauses0),
+	(
+		% Don't do this when making a `.opt' file.
+		% intermod.m needs to perform a similar transformation
+		% which this transformation would interfere with (intermod.m
+		% places the original argument terms, not just the argument
+		% variables in the clause head, and this pass would make it
+		% difficult to work out what were the original arguments).
+		globals__lookup_bool_option(Globals,
+			make_optimization_interface, no),
+
+		Clauses0 = [SingleClause0]
+	->
+		SingleClause0 = clause(A, Goal0, C, D),
+		clauses_info_headvars(ClausesInfo0, HeadVars0),
+		clauses_info_varset(ClausesInfo0, VarSet0),
+
+		Goal0 = _ - GoalInfo0,
+		goal_to_conj_list(Goal0, Conj0),
+		improve_single_clause_headvars(Conj0, HeadVars0, [],
+			VarSet0, VarSet, map__init, Subst, [], RevConj),
+
+		goal_info_get_nonlocals(GoalInfo0, NonLocals0),
+		goal_util__rename_vars_in_var_set(NonLocals0, no,
+			Subst, NonLocals),
+		goal_info_set_nonlocals(GoalInfo0, NonLocals, GoalInfo),
+		conj_list_to_goal(list__reverse(RevConj), GoalInfo, Goal),
+
+		apply_partial_map_to_list(HeadVars0, Subst, HeadVars),
+		clauses_info_set_headvars(ClausesInfo0,
+			HeadVars, ClausesInfo1),
+
+		SingleClause = clause(A, Goal, C, D),
+		clauses_info_set_clauses(ClausesInfo1,
+			[SingleClause], ClausesInfo2),
+		clauses_info_set_varset(ClausesInfo2, VarSet, ClausesInfo),
+		pred_info_set_clauses_info(PredInfo0, ClausesInfo, PredInfo)
+	;
+		PredInfo = PredInfo0
+	).
+
+:- pred improve_single_clause_headvars(list(hlds_goal)::in, list(prog_var)::in,
+	list(prog_var)::in, prog_varset::in, prog_varset::out,
+	map(prog_var, prog_var)::in, map(prog_var, prog_var)::out,
+	list(hlds_goal)::in, list(hlds_goal)::out) is det.
+
+improve_single_clause_headvars([], _, _, VarSet, VarSet,
+		Subst, Subst, RevConj, RevConj).
+improve_single_clause_headvars([Goal | Conj0], HeadVars, SeenVars0,
+		VarSet0, VarSet, Subst0, Subst, RevConj0, RevConj) :-
+	(
+		Goal = unify(LVar, var(RVar), _, _, _) - _, 
+		( list__member(LVar, HeadVars) ->
+			HeadVar = LVar,
+			OtherVar = RVar
+		; list__member(RVar, HeadVars) ->
+			HeadVar = RVar,
+			OtherVar = LVar
+		;
+			fail
+		),
+
+		% The headvars must be distinct variables, so check
+		% that this variable doesn't already appear in the
+		% argument list.
+		\+ list__member(OtherVar, HeadVars),
+		\+ list__member(OtherVar, SeenVars0)
+	->
+		%
+		% If the headvar doesn't appear elsewhere the
+		% unification can be removed. This check is
+		% just to be safe -- the unification should
+		% always be removable.
+		%
+		(
+			some [OtherGoal] (
+				( list__member(OtherGoal, Conj0)
+				; list__member(OtherGoal, RevConj0)
+				),
+				OtherGoal = _ - OtherGoalInfo,
+				goal_info_get_nonlocals(OtherGoalInfo,
+					OtherNonLocals),
+				set__member(HeadVar, OtherNonLocals)
+			)
+		->
+			RevConj1 = [Goal | RevConj0]
+		;
+			RevConj1 = RevConj0
+		),
+
+		%
+		% If the variable wasn't named, use the `HeadVar__n' name.
+		%
+		(
+			\+ varset__search_name(VarSet0, OtherVar, _),
+			varset__search_name(VarSet0, HeadVar, HeadVarName)
+		->
+			varset__name_var(VarSet0, OtherVar,
+				HeadVarName, VarSet1)
+		;
+			VarSet1 = VarSet0
+		),
+
+		Subst1 = map__det_insert(Subst0, HeadVar, OtherVar),
+		SeenVars = [OtherVar | SeenVars0]
+	;
+		RevConj1 = [Goal | RevConj0],
+		VarSet1 = VarSet0,
+		Subst1 = Subst0,
+		SeenVars = SeenVars0
+	),
+	improve_single_clause_headvars(Conj0, HeadVars, SeenVars,
+		VarSet1, VarSet, Subst1, Subst, RevConj1, RevConj).
 
 %-----------------------------------------------------------------------------%
 
Index: tests/debugger/browse_pretty.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browse_pretty.exp,v
retrieving revision 1.9
diff -u -u -r1.9 browse_pretty.exp
--- tests/debugger/browse_pretty.exp	16 Apr 2002 13:54:32 -0000	1.9
+++ tests/debugger/browse_pretty.exp	4 Jun 2002 17:15:34 -0000
@@ -4,7 +4,7 @@
 mdb> goto 3
        3:      2  2 EXIT pred browse_pretty:big_data/1-0 (det) browse_pretty.m:19 (browse_pretty.m:13)
 mdb> print *
-       HeadVar__1             	big(big(big(small, [|]/2, small), [|](1, [|]/2), small), [|](1, [|](2, [|]/2)), big(big(small, [|]/2, big/3), [|]/2, small))
+       Data (arg 1)           	big(big(big(small, [|]/2, small), [|](1, [|]/2), small), [|](1, [|](2, [|]/2)), big(big(small, [|]/2, big/3), [|]/2, small))
 mdb> browse 1
 browser> set format raw_pretty
 browser> set depth 10
Index: tests/debugger/browser_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.exp,v
retrieving revision 1.11
diff -u -u -r1.11 browser_test.exp
--- tests/debugger/browser_test.exp	7 Nov 2001 06:43:10 -0000	1.11
+++ tests/debugger/browser_test.exp	4 Jun 2002 17:17:56 -0000
@@ -5,11 +5,11 @@
        3:      2  2 EXIT pred browser_test:big_data/1-0 (det) browser_test.m:18 (browser_test.m:12)
 mdb> set format pretty
 mdb> print *
-       HeadVar__1             	
+       Data (arg 1)           	
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> set -A format verbose
 mdb> print *
-       HeadVar__1             	
+       Data (arg 1)           	
 big
 1-big
 | 1-big
@@ -23,12 +23,12 @@
   big(big(small, 4, big(small, 5, small)), 6, small))
 mdb> set -AP format flat
 mdb> print -f 1
-       HeadVar__1             	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
+       Data (arg 1)           	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> print -r 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big(big(big(...), ...), 3, ...)
 mdb> print -v 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big
 1-big
 | 1-big
@@ -47,7 +47,7 @@
   3-small
 
 mdb> print -p 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big(
   big(big(small, 1, small), 2, small), 
   3, 
@@ -59,7 +59,7 @@
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> browse -f 1; ls; quit
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big(small, 5, small)), 6, small))
-mdb> browse HeadVar__1
+mdb> browse Data
 browser> ls
 big(
   big(big(small, 1, small), 2, small), 
@@ -86,14 +86,14 @@
 browser> quit
 mdb> set -A -f depth 1
 mdb> print *
-       HeadVar__1             	big(big/3, 3, big/3)
-mdb> print HeadVar__1/1
-       HeadVar__1             	big(big(small, 1, small), 2, small)
+       Data (arg 1)           	big(big/3, 3, big/3)
+mdb> print Data/1
+       Data (arg 1)           	big(big(small, 1, small), 2, small)
 mdb> set -f depth 3
 mdb> print 1
-       HeadVar__1             	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
-mdb> print HeadVar__1/1/2
-       HeadVar__1             	2
+       Data (arg 1)           	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
+mdb> print Data/1/2
+       Data (arg 1)           	2
 mdb> print 1^1^2^3
 mdb: the path 3 does not exist.
 mdb> retry
Index: tests/debugger/browser_test.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.exp2,v
retrieving revision 1.12
diff -u -u -r1.12 browser_test.exp2
--- tests/debugger/browser_test.exp2	19 Nov 2001 07:32:28 -0000	1.12
+++ tests/debugger/browser_test.exp2	5 Jun 2002 09:44:52 -0000
@@ -5,11 +5,11 @@
        3:      2  2 EXIT pred browser_test:big_data/1-0 (det) browser_test.m:18 (browser_test.m:12)
 mdb> set format pretty
 mdb> print *
-       HeadVar__1             	
+       Data (arg 1)           	
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> set -A format verbose
 mdb> print *
-       HeadVar__1             	
+       Data (arg 1)           	
 big
 1-big
 | 1-big
@@ -23,12 +23,12 @@
   big(big(small, 4, big(small, 5, small)), 6, small))
 mdb> set -AP format flat
 mdb> print -f 1
-       HeadVar__1             	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
+       Data (arg 1)           	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> print -r 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big(big(big(...), ...), 3, ...)
 mdb> print -v 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big
 1-big
 | 1-big
@@ -47,7 +47,7 @@
   3-small
 
 mdb> print -p 1
-       HeadVar__1             	
+       Data (arg 1)           	
 big(
   big(big(small, 1, small), 2, small), 
   3, 
@@ -59,7 +59,7 @@
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
 mdb> browse -f 1; ls; quit
 big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big(small, 5, small)), 6, small))
-mdb> browse HeadVar__1
+mdb> browse Data
 browser> ls
 big(
   big(big(small, 1, small), 2, small), 
@@ -86,14 +86,14 @@
 browser> quit
 mdb> set -A -f depth 1
 mdb> print *
-       HeadVar__1             	big(big/3, 3, big/3)
-mdb> print HeadVar__1/1
-       HeadVar__1             	big(big(small, 1, small), 2, small)
+       Data (arg 1)           	big(big/3, 3, big/3)
+mdb> print Data/1
+       Data (arg 1)           	big(big(small, 1, small), 2, small)
 mdb> set -f depth 3
 mdb> print 1
-       HeadVar__1             	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
-mdb> print HeadVar__1/1/2
-       HeadVar__1             	2
+       Data (arg 1)           	big(big(big(small, 1, small), 2, small), 3, big(big(small, 4, big/3), 6, small))
+mdb> print Data/1/2
+       Data (arg 1)           	2
 mdb> print 1^1^2^3
 mdb: the path 3 does not exist.
 mdb> retry
Index: tests/debugger/browser_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/browser_test.inp,v
retrieving revision 1.6
diff -u -u -r1.6 browser_test.inp
--- tests/debugger/browser_test.inp	23 Feb 2001 04:15:17 -0000	1.6
+++ tests/debugger/browser_test.inp	4 Jun 2002 16:50:10 -0000
@@ -13,7 +13,7 @@
 print --xyzzy 1
 browse 1; print; quit
 browse -f 1; ls; quit
-browse HeadVar__1
+browse Data
 ls
 cd /1
 ls
@@ -28,10 +28,10 @@
 quit
 set -A -f depth 1
 print *
-print HeadVar__1/1
+print Data/1
 set -f depth 3
 print 1
-print HeadVar__1/1/2
+print Data/1/2
 print 1^1^2^3
 retry
 continue -a
Index: tests/debugger/completion.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/completion.exp,v
retrieving revision 1.6
diff -u -u -r1.6 completion.exp
--- tests/debugger/completion.exp	8 Apr 2002 04:45:37 -0000	1.6
+++ tests/debugger/completion.exp	5 Jun 2002 08:46:42 -0000
@@ -28,10 +28,10 @@
      Prints the names of all the known variables in the current
      environment, together with an ordinal number for each variable.
 mdb> 
-*           --pretty    -f          -v          exception   
---flat      --verbose   -p          HeadVar__1  goal        
-p --flat HeadVar__1 
-       HeadVar__1             	state('<<c_pointer>>')
+*          --pretty   -f         -v         exception  
+--flat     --verbose  -p         DCG_0      goal       
+p --flat DCG_0 
+       DCG_0 (arg 1)          	state('<<c_pointer>>')
 mdb> 
 stack       stack_regs  
 stack --detailed 
Index: tests/debugger/completion.inp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/completion.inp,v
retrieving revision 1.3
diff -u -u -r1.3 completion.inp
--- tests/debugger/completion.inp	8 Mar 2002 07:18:08 -0000	1.3
+++ tests/debugger/completion.inp	5 Jun 2002 08:08:21 -0000
@@ -1,7 +1,7 @@
 echo on
 register --quiet
 @h at e@v at a@
-p --f@@H@
+p --f@@D@
 sta@ @
 proc at e@complet@:@1
 set --f at fo@p@
Index: tests/debugger/exception_cmd.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/exception_cmd.exp,v
retrieving revision 1.3
diff -u -u -r1.3 exception_cmd.exp
--- tests/debugger/exception_cmd.exp	1 Nov 2000 04:23:03 -0000	1.3
+++ tests/debugger/exception_cmd.exp	4 Jun 2002 17:15:57 -0000
@@ -4,7 +4,7 @@
 mdb> exception
        4:      2  2 EXCP pred exception_cmd:test/2-0 (det)
 mdb> print *
-       HeadVar__1             	42
+       X (arg 1)              	42
 mdb> continue
 Uncaught exception:
 Software Error: oops
Index: tests/debugger/exception_vars.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/exception_vars.exp,v
retrieving revision 1.6
diff -u -u -r1.6 exception_vars.exp
--- tests/debugger/exception_vars.exp	1 Nov 2000 04:23:04 -0000	1.6
+++ tests/debugger/exception_vars.exp	4 Jun 2002 17:16:07 -0000
@@ -6,7 +6,7 @@
 mdb> finish
        4:      2  2 EXCP pred exception_vars:test/2-0 (det)
 mdb> print *
-       HeadVar__1             	42
+       X (arg 1)              	42
 mdb> continue
 Uncaught exception:
 Software Error: oops
Index: tests/debugger/exception_vars.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/exception_vars.exp2,v
retrieving revision 1.7
diff -u -u -r1.7 exception_vars.exp2
--- tests/debugger/exception_vars.exp2	1 Nov 2000 04:23:04 -0000	1.7
+++ tests/debugger/exception_vars.exp2	5 Jun 2002 09:43:38 -0000
@@ -6,7 +6,7 @@
 mdb> finish
        6:      2  2 EXCP pred exception_vars:test/2-0 (det)
 mdb> print *
-       HeadVar__1             	42
+       X (arg 1)              	42
 mdb> continue
 Uncaught exception:
 Software Error: oops
Index: tests/debugger/existential_type_classes.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp,v
retrieving revision 1.11
diff -u -u -r1.11 existential_type_classes.exp
--- tests/debugger/existential_type_classes.exp	11 Feb 2002 12:52:55 -0000	1.11
+++ tests/debugger/existential_type_classes.exp	4 Jun 2002 17:16:14 -0000
@@ -12,7 +12,7 @@
        2:      2  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:51)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	42
+       X (arg 1)              	42
 mdb> 
        3:      3  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -35,13 +35,13 @@
        9:      2  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:51)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	42
-       HeadVar__2             	84
+       X (arg 1)              	42
+       N (arg 2)              	84
 mdb> continue -a
       10:      6  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:52)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"blah"
+       X (arg 1)              	"blah"
 mdb> 
       11:      7  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -64,8 +64,8 @@
       17:      6  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:52)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"blah"
-       HeadVar__2             	4
+       X (arg 1)              	"blah"
+       N (arg 2)              	4
 mdb> continue -a
       18:     10  2 CALL existential_type_classes.m:74 (from existential_type_classes.m:53)
                          func existential_type_classes:my_exist_t/0-0 (det)
@@ -74,7 +74,7 @@
       20:     11  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:53)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
+       X (arg 1)              	43
 mdb> 
       21:     12  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -97,8 +97,8 @@
       27:     11  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:53)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
-       HeadVar__2             	86
+       X (arg 1)              	43
+       N (arg 2)              	86
 mdb> continue -a
       28:     15  2 CALL existential_type_classes.m:70 (from existential_type_classes.m:54)
                          func existential_type_classes:call_my_exist_t/0-0 (det)
@@ -111,7 +111,7 @@
       32:     17  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:54)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
+       X (arg 1)              	43
 mdb> 
       33:     18  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -134,8 +134,8 @@
       39:     17  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:54)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
-       HeadVar__2             	86
+       X (arg 1)              	43
+       N (arg 2)              	86
 mdb> continue -a
       40:     21  2 CALL existential_type_classes.m:82 (from existential_type_classes.m:55)
                          func existential_type_classes:my_univ/1-0 (det)
@@ -148,7 +148,7 @@
       44:     23  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:55)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	45
+       X (arg 1)              	45
 mdb> 
       45:     24  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -171,8 +171,8 @@
       51:     23  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:55)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	45
-       HeadVar__2             	90
+       X (arg 1)              	45
+       N (arg 2)              	90
 mdb> 
       52:     27  2 CALL existential_type_classes.m:82 (from existential_type_classes.m:56)
                          func existential_type_classes:my_univ/1-0 (det)
@@ -183,12 +183,12 @@
       54:     28  2 CALL existential_type_classes.m:72 (from existential_type_classes.m:56)
                          func existential_type_classes:call_my_univ_value/1-0 (det)
 mdb> P
-       HeadVar__1             	my_univ('<<c_pointer>>')
+       Univ (arg 1)           	my_univ('<<c_pointer>>')
 mdb> 
       55:     29  3 CALL existential_type_classes.m:76 (from existential_type_classes.m:72)
                          func existential_type_classes:my_univ_value/1-0 (det)
 mdb> P
-       Univ                   	my_univ('<<c_pointer>>')
+       HeadVar__1             	my_univ('<<c_pointer>>')
 mdb> continue -a
       56:     29  3 EXIT existential_type_classes.m:76 (from existential_type_classes.m:72)
                          func existential_type_classes:my_univ_value/1-0 (det)
@@ -197,7 +197,7 @@
       58:     30  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:56)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"something"
+       X (arg 1)              	"something"
 mdb> continue -S
 84
 4
Index: tests/debugger/existential_type_classes.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/existential_type_classes.exp2,v
retrieving revision 1.11
diff -u -u -r1.11 existential_type_classes.exp2
--- tests/debugger/existential_type_classes.exp2	17 Feb 2002 10:54:45 -0000	1.11
+++ tests/debugger/existential_type_classes.exp2	5 Jun 2002 09:43:43 -0000
@@ -12,7 +12,7 @@
        2:      2  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:51)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	42
+       X (arg 1)              	42
 mdb> 
        3:      3  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -35,13 +35,13 @@
        9:      2  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:51)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	42
-       HeadVar__2             	84
+       X (arg 1)              	42
+       N (arg 2)              	84
 mdb> continue -a
       10:      6  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:52)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"blah"
+       X (arg 1)              	"blah"
 mdb> 
       11:      7  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -68,8 +68,8 @@
       19:      6  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:52)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"blah"
-       HeadVar__2             	4
+       X (arg 1)              	"blah"
+       N (arg 2)              	4
 mdb> continue -a
       20:     11  2 CALL existential_type_classes.m:74 (from existential_type_classes.m:53)
                          func existential_type_classes:my_exist_t/0-0 (det)
@@ -78,7 +78,7 @@
       22:     12  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:53)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
+       X (arg 1)              	43
 mdb> 
       23:     13  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -101,8 +101,8 @@
       29:     12  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:53)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
-       HeadVar__2             	86
+       X (arg 1)              	43
+       N (arg 2)              	86
 mdb> continue -a
       30:     16  2 CALL existential_type_classes.m:70 (from existential_type_classes.m:54)
                          func existential_type_classes:call_my_exist_t/0-0 (det)
@@ -115,7 +115,7 @@
       34:     18  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:54)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
+       X (arg 1)              	43
 mdb> 
       35:     19  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -138,8 +138,8 @@
       41:     18  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:54)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	43
-       HeadVar__2             	86
+       X (arg 1)              	43
+       N (arg 2)              	86
 mdb> continue -a
       42:     22  2 CALL existential_type_classes.m:82 (from existential_type_classes.m:55)
                          func existential_type_classes:my_univ/1-0 (det)
@@ -152,7 +152,7 @@
       46:     24  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:55)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	45
+       X (arg 1)              	45
 mdb> 
       47:     25  3 CALL (from existential_type_classes.m:68)
                          pred existential_type_classes:foo/2-0 (det)
@@ -175,8 +175,8 @@
       53:     24  2 EXIT existential_type_classes.m:68 (from existential_type_classes.m:55)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	45
-       HeadVar__2             	90
+       X (arg 1)              	45
+       N (arg 2)              	90
 mdb> 
       54:     28  2 CALL existential_type_classes.m:82 (from existential_type_classes.m:56)
                          func existential_type_classes:my_univ/1-0 (det)
@@ -187,12 +187,12 @@
       56:     29  2 CALL existential_type_classes.m:72 (from existential_type_classes.m:56)
                          func existential_type_classes:call_my_univ_value/1-0 (det)
 mdb> P
-       HeadVar__1             	my_univ('<<c_pointer>>')
+       Univ (arg 1)           	my_univ('<<c_pointer>>')
 mdb> 
       57:     30  3 CALL existential_type_classes.m:76 (from existential_type_classes.m:72)
                          func existential_type_classes:my_univ_value/1-0 (det)
 mdb> P
-       Univ                   	my_univ('<<c_pointer>>')
+       HeadVar__1             	my_univ('<<c_pointer>>')
 mdb> continue -a
       58:     30  3 EXIT existential_type_classes.m:76 (from existential_type_classes.m:72)
                          func existential_type_classes:my_univ_value/1-0 (det)
@@ -201,7 +201,7 @@
       60:     31  2 CALL existential_type_classes.m:68 (from existential_type_classes.m:56)
                          pred existential_type_classes:do_foo/2-0 (det)
 mdb> P
-       HeadVar__1             	"something"
+       X (arg 1)              	"something"
 mdb> continue -S
 84
 4
Index: tests/debugger/interactive.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interactive.exp,v
retrieving revision 1.5
diff -u -u -r1.5 interactive.exp
--- tests/debugger/interactive.exp	29 Apr 2002 08:22:06 -0000	1.5
+++ tests/debugger/interactive.exp	5 Jun 2002 09:45:53 -0000
@@ -2,7 +2,7 @@
 mdb> echo on
 Command echo enabled.
 mdb> print *
-       HeadVar__1             	state('<<c_pointer>>')
+       DCG_0 (arg 1)          	state('<<c_pointer>>')
 mdb> 
        2:      2  2 CALL pred interactive:data/1-0 (det) interactive.m:40 (interactive.m:19)
 mdb> print *
@@ -14,7 +14,7 @@
 mdb> 
        4:      3  2 CALL pred interactive:queen/2-0 (nondet) interactive.m:42 (interactive.m:19)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        5:      4  3 CALL pred interactive:qperm/2-0 (nondet) interactive.m:46 (interactive.m:43)
 mdb> print *
@@ -40,9 +40,9 @@
 Ancestor level set to 2:
    2  pred interactive:queen/2-0 (nondet) interactive.m:43
 mdb> vars
-        1 HeadVar__1
+        1 Data (arg 1)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        9:      5  4 EXIT pred interactive:qdelete/3-0 (nondet) interactive.m:52 (interactive.m:48)
 mdb> print HeadVar__1
@@ -267,7 +267,7 @@
       39:     15  3 SWTC pred interactive:safe/1-0 (semidet) s2; interactive.m:57
       40:     16  4 CALL pred interactive:nodiag/3-0 (semidet) interactive.m:61 (interactive.m:58)
       41:     16  4 SWTC pred interactive:nodiag/3-0 (semidet) s2; interactive.m:62
-      42:     16  4 THEN pred interactive:nodiag/3-0 (semidet) s2;c4;t; interactive.m:66
+      42:     16  4 THEN pred interactive:nodiag/3-0 (semidet) s2;c6;t; interactive.m:66
       43:     16  4 FAIL pred interactive:nodiag/3-0 (semidet) interactive.m:61 (interactive.m:58)
       44:     15  3 FAIL pred interactive:safe/1-0 (semidet) interactive.m:56 (interactive.m:44)
       45:      4  3 REDO pred interactive:qperm/2-0 (nondet) interactive.m:46 (interactive.m:43)
Index: tests/debugger/interpreter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.exp,v
retrieving revision 1.13
diff -u -u -r1.13 interpreter.exp
--- tests/debugger/interpreter.exp	25 Sep 2001 09:37:10 -0000	1.13
+++ tests/debugger/interpreter.exp	4 Jun 2002 17:16:44 -0000
@@ -20,16 +20,16 @@
 mdb> goto 30
       30:     16 12 CALL pred interpreter:database_assert_clause/4-0 (det)
 mdb> print *
-       HeadVar__1             	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [|](clause(varset/3, functor/3, functor/3), [|](clause/3, [])))
-       HeadVar__2             	varset(var_supply(0), empty, empty)
-       HeadVar__3             	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 26))
+       Database (arg 1)       	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [|](clause(varset/3, functor/3, functor/3), [|](clause/3, [])))
+       VarSet (arg 2)         	varset(var_supply(0), empty, empty)
+       Term (arg 3)           	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 26))
 mdb> finish -a
       31:     16 12 ELSE pred interpreter:database_assert_clause/4-0 (det) e;
       32:     16 12 EXIT pred interpreter:database_assert_clause/4-0 (det)
 mdb> print *
-       HeadVar__1             	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [|](clause(varset/3, functor/3, functor/3), [|](clause/3, [])))
-       HeadVar__2             	varset(var_supply(0), empty, empty)
-       HeadVar__3             	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 26))
+       Database (arg 1)       	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [|](clause(varset/3, functor/3, functor/3), [|](clause/3, [])))
+       VarSet (arg 2)         	varset(var_supply(0), empty, empty)
+       Term (arg 3)           	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 26))
        HeadVar__4             	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [|](clause(varset/3, functor/3, functor/3), [|](clause/3, [|]/2)))
 mdb> 
       33:     17 12 CALL pred interpreter:consult_until_eof/4-0 (det)
Index: tests/debugger/interpreter.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/interpreter.exp2,v
retrieving revision 1.12
diff -u -u -r1.12 interpreter.exp2
--- tests/debugger/interpreter.exp2	26 Sep 2001 04:33:17 -0000	1.12
+++ tests/debugger/interpreter.exp2	5 Jun 2002 09:44:03 -0000
@@ -9,27 +9,27 @@
 
       11:      6  3 CALL pred interpreter:consult/5-0 (det)
 mdb> vars
-        1 HeadVar__1
-        2 HeadVar__2
-        3 HeadVar__4
+        1 File (arg 1)
+        2 Database0 (arg 2)
+        3 DCG_0 (arg 4)
 mdb> print *
-       HeadVar__1             	"interpreter.m"
-       HeadVar__2             	[]
-       HeadVar__4             	state('<<c_pointer>>')
+       File (arg 1)           	"interpreter.m"
+       Database0 (arg 2)      	[]
+       DCG_0 (arg 4)          	state('<<c_pointer>>')
 mdb> goto 30
 Consulting file `interpreter.m'...
       30:     14  6 EXIT pred interpreter:database_assert_clause/4-0 (det)
 mdb> print *
-       HeadVar__1             	[]
-       HeadVar__2             	varset(var_supply(0), empty, empty)
-       HeadVar__3             	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 22))
+       Database (arg 1)       	[]
+       VarSet (arg 2)         	varset(var_supply(0), empty, empty)
+       Term (arg 3)           	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 22))
        HeadVar__4             	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [])
 mdb> finish -a
 This command is a no-op from this port.
 mdb> print *
-       HeadVar__1             	[]
-       HeadVar__2             	varset(var_supply(0), empty, empty)
-       HeadVar__3             	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 22))
+       Database (arg 1)       	[]
+       VarSet (arg 2)         	varset(var_supply(0), empty, empty)
+       Term (arg 3)           	functor(atom(":-"), [|](functor(atom/1, [|]/2, context/2), []), context("interpreter.m", 22))
        HeadVar__4             	[|](clause(varset(var_supply/1, empty, empty), functor(atom/1, [|]/2, context/2), functor(atom/1, [], context/2)), [])
 mdb> 
       31:     16  6 CALL pred interpreter:consult_until_eof/4-0 (det)
Index: tests/debugger/lval_desc_array.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/lval_desc_array.exp,v
retrieving revision 1.1
diff -u -u -r1.1 lval_desc_array.exp
--- tests/debugger/lval_desc_array.exp	10 Dec 2001 06:50:14 -0000	1.1
+++ tests/debugger/lval_desc_array.exp	4 Jun 2002 17:16:59 -0000
@@ -10,7 +10,7 @@
 Ancestor level set to 1:
    1  pred lval_desc_array:perform_increments/2-0 (det)
 mdb> print *
-       HeadVar__1             	0
+       DCG_0 (arg 1)          	0
        DCG_1                  	1
        DCG_2                  	2
        DCG_3                  	3
Index: tests/debugger/multi_parameter.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp,v
retrieving revision 1.10
diff -u -u -r1.10 multi_parameter.exp
--- tests/debugger/multi_parameter.exp	3 Jul 2001 02:49:26 -0000	1.10
+++ tests/debugger/multi_parameter.exp	4 Jun 2002 17:17:03 -0000
@@ -7,7 +7,7 @@
        2:      2  2 CALL pred multi_parameter:foo/2-0 (det)
                          multi_parameter.m:32 (from multi_parameter.m:24)
 mdb> print *
-       HeadVar__1             	'z'
+       X (arg 1)              	'z'
 mdb> 
        3:      3  3 CALL pred multi_parameter:a/2-0 (det)
                          (from multi_parameter.m:32)
@@ -34,12 +34,12 @@
        7:      2  2 EXIT pred multi_parameter:foo/2-0 (det)
                          multi_parameter.m:32 (from multi_parameter.m:24)
 mdb> print *
-       HeadVar__1             	'z'
-       HeadVar__2             	122
+       X (arg 1)              	'z'
+       Y (arg 2)              	122
 mdb> 
 122
        8:      1  1 EXIT pred multi_parameter:main/2-0 (det)
                          multi_parameter.m:23
 mdb> print *
-       HeadVar__2             	state('<<c_pointer>>')
+       DCG_2 (arg 2)          	state('<<c_pointer>>')
 mdb> continue -S
Index: tests/debugger/multi_parameter.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/multi_parameter.exp2,v
retrieving revision 1.10
diff -u -u -r1.10 multi_parameter.exp2
--- tests/debugger/multi_parameter.exp2	11 Jul 2001 05:21:20 -0000	1.10
+++ tests/debugger/multi_parameter.exp2	5 Jun 2002 14:54:35 -0000
@@ -7,7 +7,7 @@
        2:      2  2 CALL pred multi_parameter:foo/2-0 (det)
                          multi_parameter.m:32 (from multi_parameter.m:24)
 mdb> print *
-       HeadVar__1             	'z'
+       X (arg 1)              	'z'
 mdb> 
        3:      3  3 CALL pred multi_parameter:a/2-0 (det)
                          (from multi_parameter.m:32)
@@ -22,13 +22,13 @@
        5:      5  5 CALL pred char:to_int/2-0 (det)
                          char.m:NNNN (from multi_parameter.m:20)
 mdb> print *
-       Character              	'z'
+       Character (arg 1)      	'z'
 mdb> 
        6:      5  5 EXIT pred char:to_int/2-0 (det)
                          char.m:NNNN (from multi_parameter.m:20)
 mdb> print *
-       Character              	'z'
-       Int                    	122
+       Character (arg 1)      	'z'
+       Int (arg 2)            	122
 mdb> 
        7:      4  4 EXIT pred multi_parameter:ClassMethod_for_multi_parameter__m____character__arity0__int__arity0______multi_parameter__a_2/2-0 (det)
                          multi_parameter.m:20
Index: tests/debugger/nondet_stack.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/nondet_stack.exp,v
retrieving revision 1.3
diff -u -u -r1.3 nondet_stack.exp
--- tests/debugger/nondet_stack.exp	17 Apr 2002 00:52:57 -0000	1.3
+++ tests/debugger/nondet_stack.exp	4 Jun 2002 17:17:09 -0000
@@ -165,7 +165,7 @@
  succip: unnamed label
  succfr: non  10 
  on main nondet branch non 135
-       HeadVar__1             [1, 2, 3, 4, 5]
+       Data (arg 1)           [1, 2, 3, 4, 5]
        TypeCtorInfo_5         int
 non  14: temp
  redoip: label UNKNOWN
@@ -741,7 +741,9 @@
  succfr: non 132 
  internal frame on nondet side branch non 158
        HeadVar__2             [4, 5]
+       A                      4
        TypeInfo_for_T         int
+       Z                      [5]
 non 132: ordinary, 13 words
  redoip: unnamed label
  redofr: non 132 
@@ -749,7 +751,9 @@
  succfr: non 119 
  internal frame on nondet side branch non 158
        HeadVar__2             [2, 4, 5]
+       A                      2
        TypeInfo_for_T         int
+       Z                      [4, 5]
 non 119: ordinary, 13 words
  redoip: unnamed label
  redofr: non 119 
@@ -784,7 +788,9 @@
  succfr: non  71 
  internal frame on nondet side branch non  97
        HeadVar__2             [2, 3, 4, 5]
+       A                      2
        TypeInfo_for_T         int
+       Z                      [3, 4, 5]
 non  71: ordinary, 13 words
  redoip: unnamed label
  redofr: non  71 
@@ -825,7 +831,7 @@
  succip: unnamed label
  succfr: non  10 
  internal frame on nondet side branch non 247
-       HeadVar__1             [1, 2, 3, 4, 5]
+       Data (arg 1)           [1, 2, 3, 4, 5]
        TypeCtorInfo_5         int
 non  14: temp
  redoip: label UNKNOWN
Index: tests/debugger/nondet_stack.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/nondet_stack.exp2,v
retrieving revision 1.3
diff -u -u -r1.3 nondet_stack.exp2
--- tests/debugger/nondet_stack.exp2	24 Apr 2002 02:24:11 -0000	1.3
+++ tests/debugger/nondet_stack.exp2	5 Jun 2002 09:44:21 -0000
@@ -165,7 +165,7 @@
  succip: unnamed label
  succfr: non  10 
  on main nondet branch non 154
-       HeadVar__1             [1, 2, 3, 4, 5]
+       Data (arg 1)           [1, 2, 3, 4, 5]
        TypeCtorInfo_5         int
 non  14: temp
  redoip: unnamed label
@@ -741,7 +741,9 @@
  succfr: non 152 
  internal frame on nondet side branch non 184
        HeadVar__2             [4, 5]
+       A                      4
        TypeInfo_for_T         int
+       Z                      [5]
 non 152: ordinary, 16 words
  redoip: unnamed label
  redofr: non 152 
@@ -749,7 +751,9 @@
  succfr: non 136 
  internal frame on nondet side branch non 184
        HeadVar__2             [2, 4, 5]
+       A                      2
        TypeInfo_for_T         int
+       Z                      [4, 5]
 non 136: ordinary, 15 words
  redoip: unnamed label
  redofr: non 136 
@@ -784,7 +788,9 @@
  succfr: non  80 
  internal frame on nondet side branch non 112
        HeadVar__2             [2, 3, 4, 5]
+       A                      2
        TypeInfo_for_T         int
+       Z                      [3, 4, 5]
 non  80: ordinary, 15 words
  redoip: unnamed label
  redofr: non  80 
@@ -825,7 +831,7 @@
  succip: unnamed label
  succfr: non  10 
  internal frame on nondet side branch non 285
-       HeadVar__1             [1, 2, 3, 4, 5]
+       Data (arg 1)           [1, 2, 3, 4, 5]
        TypeCtorInfo_5         int
 non  14: temp
  redoip: unnamed label
Index: tests/debugger/polymorphic_output.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/polymorphic_output.exp2,v
retrieving revision 1.10
diff -u -u -r1.10 polymorphic_output.exp2
--- tests/debugger/polymorphic_output.exp2	17 Feb 2002 10:54:45 -0000	1.10
+++ tests/debugger/polymorphic_output.exp2	5 Jun 2002 09:44:29 -0000
@@ -56,13 +56,13 @@
 mdb> c
        9:      6  4 CALL func std_util:det_arg/2-0 (det)
 mdb> P
-       HeadVar__1             	two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
-       HeadVar__2             	3
+       Type (arg 1)           	two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
+       Index (arg 2)          	3
 mdb> f
       10:      6  4 EXCP func std_util:det_arg/2-0 (det)
 mdb> P
-       HeadVar__1             	two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
-       HeadVar__2             	3
+       Type (arg 1)           	two("three", 3, three("four", 4, "one", 1, empty, empty, empty), two/4)
+       Index (arg 2)          	3
 mdb> c
 Uncaught exception:
 Software Error: det_arg: argument has wrong type
Index: tests/debugger/queens.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp,v
retrieving revision 1.21
diff -u -u -r1.21 queens.exp
--- tests/debugger/queens.exp	12 Mar 2002 03:40:41 -0000	1.21
+++ tests/debugger/queens.exp	4 Jun 2002 17:18:05 -0000
@@ -4,7 +4,7 @@
 mdb> retry 1
 not that many ancestors
 mdb> print *
-       HeadVar__1             	state('<<c_pointer>>')
+       DCG_0 (arg 1)          	state('<<c_pointer>>')
 mdb> 
        2:      2  2 CALL pred queens:data/1-0 (det) queens.m:39 (queens.m:15)
 mdb> print *
@@ -16,7 +16,7 @@
 mdb> 
        4:      3  2 CALL pred queens:queen/2-0 (nondet) queens.m:41 (queens.m:15)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        5:      4  3 CALL pred queens:qperm/2-0 (nondet) queens.m:45 (queens.m:42)
 mdb> print *
@@ -70,14 +70,15 @@
                            pred queens:qperm/2-0 (nondet)
 mdb> print *
        HeadVar__1             	[1, 2, 3, 4, 5]
+       L                      	[1, 2, 3, 4, 5]
 mdb> up 1
 Ancestor level set to 2:
    2  queens.m:42
       pred queens:queen/2-0 (nondet)
 mdb> vars
-        1 HeadVar__1
+        1 Data (arg 1)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        9:      5  4 EXIT queens.m:51 (from queens.m:47)
                          pred queens:qdelete/3-0 (nondet)
@@ -134,9 +135,9 @@
    5       pred queens:main/2-0 (cc_multi) (queens.m:15)
 mdb> stack -d
    0      20      10    6 pred queens:qperm/2-0 (nondet) (queens.m:45) (empty)
-   1      15       8    5 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
-   2      10       6    4 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
-   3       5       4    3 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
+   1      15       8    5 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   2      10       6    4 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   3       5       4    3 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
    4       4       3    2 pred queens:queen/2-0 (nondet) (queens.m:42) c2;
    5       1       1    1 pred queens:main/2-0 (cc_multi) (queens.m:15) ?;c2;q!;
 mdb> print *
@@ -199,7 +200,7 @@
       41:     16  4 SWTC queens.m:61
                          pred queens:nodiag/3-0 (semidet) s2;
       42:     16  4 THEN queens.m:65
-                         pred queens:nodiag/3-0 (semidet) s2;c4;t;
+                         pred queens:nodiag/3-0 (semidet) s2;c6;t;
       43:     16  4 FAIL queens.m:60 (from queens.m:57)
                          pred queens:nodiag/3-0 (semidet)
       44:     15  3 FAIL queens.m:55 (from queens.m:43)
Index: tests/debugger/queens.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/queens.exp2,v
retrieving revision 1.3
diff -u -u -r1.3 queens.exp2
--- tests/debugger/queens.exp2	12 Mar 2002 03:40:41 -0000	1.3
+++ tests/debugger/queens.exp2	5 Jun 2002 09:44:59 -0000
@@ -4,7 +4,7 @@
 mdb> retry 1
 not that many ancestors
 mdb> print *
-       HeadVar__1             	state('<<c_pointer>>')
+       DCG_0 (arg 1)          	state('<<c_pointer>>')
 mdb> 
        2:      2  2 CALL pred queens:data/1-0 (det) queens.m:39 (queens.m:15)
 mdb> print *
@@ -16,7 +16,7 @@
 mdb> 
        4:      3  2 CALL pred queens:queen/2-0 (nondet) queens.m:41 (queens.m:15)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        5:      4  3 CALL pred queens:qperm/2-0 (nondet) queens.m:45 (queens.m:42)
 mdb> print *
@@ -70,14 +70,15 @@
                            pred queens:qperm/2-0 (nondet)
 mdb> print *
        HeadVar__1             	[1, 2, 3, 4, 5]
+       L                      	[1, 2, 3, 4, 5]
 mdb> up 1
 Ancestor level set to 2:
    2  queens.m:42
       pred queens:queen/2-0 (nondet)
 mdb> vars
-        1 HeadVar__1
+        1 Data (arg 1)
 mdb> print *
-       HeadVar__1             	[1, 2, 3, 4, 5]
+       Data (arg 1)           	[1, 2, 3, 4, 5]
 mdb> 
        9:      5  4 EXIT queens.m:51 (from queens.m:47)
                          pred queens:qdelete/3-0 (nondet)
@@ -134,9 +135,9 @@
    5       pred queens:main/2-0 (cc_multi) (queens.m:15)
 mdb> stack -d
    0      20      10    6 pred queens:qperm/2-0 (nondet) (queens.m:45) (empty)
-   1      15       8    5 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
-   2      10       6    4 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
-   3       5       4    3 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c2;
+   1      15       8    5 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   2      10       6    4 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
+   3       5       4    3 pred queens:qperm/2-0 (nondet) (queens.m:49) s2;c3;
    4       4       3    2 pred queens:queen/2-0 (nondet) (queens.m:42) c2;
    5       1       1    1 pred queens:main/2-0 (cc_multi) (queens.m:15) ?;c2;q!;
 mdb> print *
@@ -199,7 +200,7 @@
       41:     16  4 SWTC queens.m:61
                          pred queens:nodiag/3-0 (semidet) s2;
       42:     16  4 THEN queens.m:65
-                         pred queens:nodiag/3-0 (semidet) s2;c4;t;
+                         pred queens:nodiag/3-0 (semidet) s2;c6;t;
       43:     16  4 FAIL queens.m:60 (from queens.m:57)
                          pred queens:nodiag/3-0 (semidet)
       44:     15  3 FAIL queens.m:55 (from queens.m:43)
Index: tests/debugger/resume_typeinfos.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/resume_typeinfos.exp,v
retrieving revision 1.1
diff -u -u -r1.1 resume_typeinfos.exp
--- tests/debugger/resume_typeinfos.exp	22 Jul 2000 11:35:18 -0000	1.1
+++ tests/debugger/resume_typeinfos.exp	4 Jun 2002 17:17:34 -0000
@@ -12,6 +12,6 @@
 mdb> finish
        6:      2  2 FAIL pred resume_typeinfos:test/2-0 (semidet)
 mdb> print *
-       HeadVar__1             	[1, 2]
+       TestList (arg 1)       	[1, 2]
 mdb> continue
 no solution.
Index: tests/debugger/resume_typeinfos.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/resume_typeinfos.exp2,v
retrieving revision 1.2
diff -u -u -r1.2 resume_typeinfos.exp2
--- tests/debugger/resume_typeinfos.exp2	28 Jul 2000 07:49:11 -0000	1.2
+++ tests/debugger/resume_typeinfos.exp2	5 Jun 2002 09:44:38 -0000
@@ -12,7 +12,7 @@
 mdb> finish
        6:      4  3 EXIT pred list:length/2-0 (det)
 mdb> print *
-       HeadVar__1             	[1, 2]
-       HeadVar__2             	2
+       L (arg 1)              	[1, 2]
+       N (arg 2)              	2
 mdb> continue
 no solution.
Index: tests/debugger/retry.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.exp,v
retrieving revision 1.2
diff -u -u -r1.2 retry.exp
--- tests/debugger/retry.exp	27 Mar 2001 05:23:23 -0000	1.2
+++ tests/debugger/retry.exp	4 Jun 2002 17:18:12 -0000
@@ -79,7 +79,7 @@
 mdb> continue
       21:     10  2 CALL pred retry:nondet/2-0 (multi)
 mdb> print *
-       HeadVar__1             	4
+       X0 (arg 1)             	4
 mdb> break nondet_2
  1: + stop  interface pred retry:nondet_2/2-0 (det)
 mdb> continue
@@ -87,7 +87,7 @@
 mdb> retry 1
       21:     10  2 CALL pred retry:nondet/2-0 (multi)
 mdb> print *
-       HeadVar__1             	4
+       X0 (arg 1)             	4
 mdb> delete *
  0: E stop  interface pred retry:nondet/2-0 (multi)
  1: E stop  interface pred retry:nondet_2/2-0 (det)
@@ -101,11 +101,11 @@
 50 51 
       89:     29  2 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	15
+       N (arg 1)              	15
 mdb> continue
       93:     30  3 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	14
+       N (arg 1)              	14
 mdb> continue
       97:     31  4 CALL pred retry:fib/2-0 (det)
 mdb> continue
@@ -115,7 +115,7 @@
 mdb> retry 2
       93:     30  3 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	14
+       N (arg 1)              	14
 mdb> next
       94:     30  3 ELSE pred retry:fib/2-0 (det) c2;e;
 mdb> retry 1
Index: tests/debugger/retry.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/retry.exp2,v
retrieving revision 1.2
diff -u -u -r1.2 retry.exp2
--- tests/debugger/retry.exp2	30 Mar 2001 03:59:18 -0000	1.2
+++ tests/debugger/retry.exp2	5 Jun 2002 09:45:04 -0000
@@ -79,7 +79,7 @@
 mdb> continue
       22:     11  3 CALL pred retry:nondet/2-0 (multi)
 mdb> print *
-       HeadVar__1             	4
+       X0 (arg 1)             	4
 mdb> break nondet_2
  1: + stop  interface pred retry:nondet_2/2-0 (det)
 mdb> continue
@@ -87,7 +87,7 @@
 mdb> retry 1
       22:     11  3 CALL pred retry:nondet/2-0 (multi)
 mdb> print *
-       HeadVar__1             	4
+       X0 (arg 1)             	4
 mdb> delete *
  0: E stop  interface pred retry:nondet/2-0 (multi)
  1: E stop  interface pred retry:nondet_2/2-0 (det)
@@ -101,11 +101,11 @@
 50 51 
      125:     47  2 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	15
+       N (arg 1)              	15
 mdb> continue
      129:     48  3 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	14
+       N (arg 1)              	14
 mdb> continue
      133:     49  4 CALL pred retry:fib/2-0 (det)
 mdb> continue
@@ -115,7 +115,7 @@
 mdb> retry 2
      129:     48  3 CALL pred retry:fib/2-0 (det)
 mdb> print *
-       HeadVar__1             	14
+       N (arg 1)              	14
 mdb> next
      130:     48  3 ELSE pred retry:fib/2-0 (det) c2;e;
 mdb> retry 1
Index: tests/debugger/tabled_read.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read.exp,v
retrieving revision 1.2
diff -u -u -r1.2 tabled_read.exp
--- tests/debugger/tabled_read.exp	20 Feb 2002 03:14:45 -0000	1.2
+++ tests/debugger/tabled_read.exp	4 Jun 2002 17:18:18 -0000
@@ -15,25 +15,25 @@
 mdb> finish -n
       35:      4  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
        8:      4  3 CALL pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__4             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       DCG_0 (arg 4)          	state('<<c_pointer>>')
 mdb> finish -n
       35:      4  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> table_io end
 io tabling ended
 mdb> continue
@@ -43,10 +43,10 @@
 mdb> finish -n
       89:     23  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	789
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	789
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
@@ -54,9 +54,9 @@
 mdb> finish -n
       83:     23  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	42
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	42
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> continue -S
 42
Index: tests/debugger/tabled_read.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read.exp2,v
retrieving revision 1.2
diff -u -u -r1.2 tabled_read.exp2
--- tests/debugger/tabled_read.exp2	20 Feb 2002 03:14:45 -0000	1.2
+++ tests/debugger/tabled_read.exp2	5 Jun 2002 09:45:08 -0000
@@ -15,25 +15,25 @@
 mdb> finish -n
       57:      4  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
        8:      4  3 CALL pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__4             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       DCG_0 (arg 4)          	state('<<c_pointer>>')
 mdb> finish -n
       57:      4  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> table_io end
 io tabling ended
 mdb> continue
@@ -43,10 +43,10 @@
 mdb> finish -n
      155:     45  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	789
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	789
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
@@ -54,9 +54,9 @@
 mdb> finish -n
      143:     45  3 EXIT pred tabled_read:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	42
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	42
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> continue -S
 42
Index: tests/debugger/tabled_read_decl.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_decl.exp,v
retrieving revision 1.2
diff -u -u -r1.2 tabled_read_decl.exp
--- tests/debugger/tabled_read_decl.exp	24 Feb 2002 11:53:40 -0000	1.2
+++ tests/debugger/tabled_read_decl.exp	4 Jun 2002 17:18:25 -0000
@@ -15,25 +15,25 @@
 mdb> finish -n
       35:      4  3 EXIT pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
        8:      4  3 CALL pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__4             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       DCG_0 (arg 4)          	state('<<c_pointer>>')
 mdb> finish -n
       35:      4  3 EXIT pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> break tabled_read_decl__poly_test
  1: + stop  interface pred tabled_read_decl:poly_test/6-0 (det)
 mdb> continue
@@ -42,11 +42,11 @@
 mdb> finish -n
       65:     13  3 EXIT pred tabled_read_decl:poly_test/6-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	['a', 'b', 'c']
-       HeadVar__3             	0
-       HeadVar__4             	456
-       HeadVar__6             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       Unused (arg 2)         	['a', 'b', 'c']
+       SoFar (arg 3)          	0
+       N (arg 4)              	456
+       DCG_2 (arg 6)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
@@ -54,11 +54,11 @@
 mdb> finish -n
       65:     13  3 EXIT pred tabled_read_decl:poly_test/6-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	['a', 'b', 'c']
-       HeadVar__3             	0
-       HeadVar__4             	456
-       HeadVar__6             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       Unused (arg 2)         	['a', 'b', 'c']
+       SoFar (arg 3)          	0
+       N (arg 4)              	456
+       DCG_2 (arg 6)          	state('<<c_pointer>>')
 mdb> delete *
  0: E stop  interface pred tabled_read_decl:test/5-0 (det)
  1: E stop  interface pred tabled_read_decl:poly_test/6-0 (det)
Index: tests/debugger/tabled_read_decl.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/tabled_read_decl.exp2,v
retrieving revision 1.2
diff -u -u -r1.2 tabled_read_decl.exp2
--- tests/debugger/tabled_read_decl.exp2	24 Feb 2002 11:53:40 -0000	1.2
+++ tests/debugger/tabled_read_decl.exp2	5 Jun 2002 09:45:12 -0000
@@ -15,25 +15,25 @@
 mdb> finish -n
       57:      4  3 EXIT pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
        8:      4  3 CALL pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__4             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       DCG_0 (arg 4)          	state('<<c_pointer>>')
 mdb> finish -n
       57:      4  3 EXIT pred tabled_read_decl:test/5-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	0
-       HeadVar__3             	123
-       HeadVar__5             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       SoFar (arg 2)          	0
+       N (arg 3)              	123
+       DCG_2 (arg 5)          	state('<<c_pointer>>')
 mdb> break tabled_read_decl__poly_test
  1: + stop  interface pred tabled_read_decl:poly_test/6-0 (det)
 mdb> continue
@@ -42,11 +42,11 @@
 mdb> finish -n
      109:     24  3 EXIT pred tabled_read_decl:poly_test/6-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	['a', 'b', 'c']
-       HeadVar__3             	0
-       HeadVar__4             	456
-       HeadVar__6             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       Unused (arg 2)         	['a', 'b', 'c']
+       SoFar (arg 3)          	0
+       N (arg 4)              	456
+       DCG_2 (arg 6)          	state('<<c_pointer>>')
 mdb> retry
 Retry across I/O operations is not always safe.
 Are you sure you want to do it? y
@@ -54,11 +54,11 @@
 mdb> finish -n
      109:     24  3 EXIT pred tabled_read_decl:poly_test/6-0 (det)
 mdb> print *
-       HeadVar__1             	'<<c_pointer>>'
-       HeadVar__2             	['a', 'b', 'c']
-       HeadVar__3             	0
-       HeadVar__4             	456
-       HeadVar__6             	state('<<c_pointer>>')
+       Stream (arg 1)         	'<<c_pointer>>'
+       Unused (arg 2)         	['a', 'b', 'c']
+       SoFar (arg 3)          	0
+       N (arg 4)              	456
+       DCG_2 (arg 6)          	state('<<c_pointer>>')
 mdb> delete *
  0: E stop  interface pred tabled_read_decl:test/5-0 (det)
  1: E stop  interface pred tabled_read_decl:poly_test/6-0 (det)
Index: tests/debugger/type_desc_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/type_desc_test.exp,v
retrieving revision 1.1
diff -u -u -r1.1 type_desc_test.exp
--- tests/debugger/type_desc_test.exp	27 Mar 2002 05:18:54 -0000	1.1
+++ tests/debugger/type_desc_test.exp	4 Jun 2002 17:17:46 -0000
@@ -13,7 +13,7 @@
 mdb> finish
        4:      3  3 EXIT func type_desc_test:get_type_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	[1, 2]
+       Val (arg 1)            	[1, 2]
        HeadVar__2             	list:list(int)
 mdb> continue
 type_desc: list:list(int)
@@ -21,7 +21,7 @@
 mdb> finish
        6:      4  3 EXIT func type_desc_test:get_type_ctor_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	list:list(int)
+       TypeDesc (arg 1)       	list:list(int)
        HeadVar__2             	list:list/1
 mdb> continue
 type_ctor_desc: list:list/1
@@ -29,7 +29,7 @@
 mdb> finish
       10:      6  3 EXIT func type_desc_test:get_type_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	["one", "two", "three"]
+       Val (arg 1)            	["one", "two", "three"]
        HeadVar__2             	list:list(string)
 mdb> continue
 type_desc: list:list(string)
@@ -37,7 +37,7 @@
 mdb> finish
       12:      7  3 EXIT func type_desc_test:get_type_ctor_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	list:list(string)
+       TypeDesc (arg 1)       	list:list(string)
        HeadVar__2             	list:list/1
 mdb> continue -S
 type_ctor_desc: list:list/1
Index: tests/debugger/type_desc_test.exp2
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/type_desc_test.exp2,v
retrieving revision 1.1
diff -u -u -r1.1 type_desc_test.exp2
--- tests/debugger/type_desc_test.exp2	27 Mar 2002 05:18:54 -0000	1.1
+++ tests/debugger/type_desc_test.exp2	5 Jun 2002 09:44:46 -0000
@@ -13,7 +13,7 @@
 mdb> finish
        6:      3  3 EXIT func type_desc_test:get_type_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	[1, 2]
+       Val (arg 1)            	[1, 2]
        HeadVar__2             	list:list(int)
 mdb> continue
 type_desc: list:list(int)
@@ -21,7 +21,7 @@
 mdb> finish
       16:      8  3 EXIT func type_desc_test:get_type_ctor_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	list:list(int)
+       TypeDesc (arg 1)       	list:list(int)
        HeadVar__2             	list:list/1
 mdb> continue
 type_ctor_desc: list:list/1
@@ -29,7 +29,7 @@
 mdb> finish
       28:     14  3 EXIT func type_desc_test:get_type_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	["one", "two", "three"]
+       Val (arg 1)            	["one", "two", "three"]
        HeadVar__2             	list:list(string)
 mdb> continue
 type_desc: list:list(string)
@@ -37,7 +37,7 @@
 mdb> finish
       38:     19  3 EXIT func type_desc_test:get_type_ctor_desc/1-0 (det)
 mdb> print *
-       HeadVar__1             	list:list(string)
+       TypeDesc (arg 1)       	list:list(string)
        HeadVar__2             	list:list/1
 mdb> continue -S
 type_ctor_desc: list:list/1
Index: tests/debugger/declarative/dependency.exp
===================================================================
RCS file: /home/mercury1/repository/tests/debugger/declarative/dependency.exp,v
retrieving revision 1.1
diff -u -u -r1.1 dependency.exp
--- tests/debugger/declarative/dependency.exp	23 Apr 2002 08:52:41 -0000	1.1
+++ tests/debugger/declarative/dependency.exp	5 Jun 2002 14:17:55 -0000
@@ -22,7 +22,7 @@
 mdb> proc_body
 	
 proc_rep(
-  [|](1, []), 
+  [|](2, []), 
   conj_rep(
     [|](
       atomic_goal_rep(
Index: tests/invalid/aditi_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/aditi_errors.err_exp,v
retrieving revision 1.1
diff -u -u -r1.1 aditi_errors.err_exp
--- tests/invalid/aditi_errors.err_exp	5 May 2000 02:42:18 -0000	1.1
+++ tests/invalid/aditi_errors.err_exp	4 Jun 2002 06:34:21 -0000
@@ -1,7 +1,7 @@
 aditi_errors.m:021: In Aditi predicate `aditi_errors:q/4':
 aditi_errors.m:021:   argument 4 is partially instantiated.
 aditi_errors.m:040: In Aditi predicate `aditi_errors:aditi_error/5':
-aditi_errors.m:040:   `HeadVar__4' is partially instantiated.
+aditi_errors.m:040:   `Thing' is partially instantiated.
 aditi_errors.m:008: In Aditi predicate `aditi_errors:aditi_error/5':
 aditi_errors.m:008:   the type of argument 5 contains abstract types.
 aditi_errors.m:040: In Aditi predicate `aditi_errors:aditi_error/5':
Index: tests/invalid/mode_inf.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/mode_inf.err_exp,v
retrieving revision 1.1
diff -u -u -r1.1 mode_inf.err_exp
--- tests/invalid/mode_inf.err_exp	28 Feb 2001 12:46:28 -0000	1.1
+++ tests/invalid/mode_inf.err_exp	4 Jun 2002 06:34:13 -0000
@@ -5,8 +5,8 @@
 mode_inf.m:009:   which does not match any of the valid modes for
 mode_inf.m:009:   the callee, because of the following error.
 mode_inf.m:011: In clause for `q(out(not_reached), out(not_reached))':
-mode_inf.m:011:   in argument 1 of clause head:
-mode_inf.m:011:   mode error in unification of `HeadVar__1' and `X'.
-mode_inf.m:011:   Variable `HeadVar__1' has instantiatedness `free',
+mode_inf.m:011:   in argument 2 of clause head:
+mode_inf.m:011:   mode error in unification of `HeadVar__2' and `X'.
+mode_inf.m:011:   Variable `HeadVar__2' has instantiatedness `free',
 mode_inf.m:011:   variable `X' has instantiatedness `free'.
 For more information, try recompiling with `-E'.
Index: tests/invalid/record_syntax_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/record_syntax_errors.err_exp,v
retrieving revision 1.5
diff -u -u -r1.5 record_syntax_errors.err_exp
--- tests/invalid/record_syntax_errors.err_exp	13 Dec 2000 00:00:55 -0000	1.5
+++ tests/invalid/record_syntax_errors.err_exp	4 Jun 2002 06:34:16 -0000
@@ -36,7 +36,6 @@
 record_syntax_errors.m:046:   argument has type `int',
 record_syntax_errors.m:046:   constant `"invalid value"' has type `string'.
 	The partial type assignment was:
-	HeadVar__1 :: (record_syntax_errors:cons)
 	Cons :: (record_syntax_errors:cons)
 	Cons0 :: (record_syntax_errors:cons)
 	V_4 :: int
Index: trace/mercury_trace_declarative.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_declarative.c,v
retrieving revision 1.54
diff -u -u -r1.54 mercury_trace_declarative.c
--- trace/mercury_trace_declarative.c	16 May 2002 13:14:54 -0000	1.54
+++ trace/mercury_trace_declarative.c	5 Jun 2002 14:48:05 -0000
@@ -203,8 +203,6 @@
 static	MR_bool		MR_trace_single_component(const char *path);
 static	MR_Word		MR_decl_make_atom(const MR_Label_Layout *layout,
 				MR_Word *saved_regs, MR_Trace_Port port);
-static	MR_bool		MR_hlds_var_is_head_var(const MR_Proc_Layout *entry,
-				int hlds_num);
 static	MR_ConstString	MR_decl_atom_name(const MR_Proc_Layout *entry);
 static	MR_Word		MR_decl_atom_args(const MR_Label_Layout *layout,
 				MR_Word *saved_regs);
@@ -945,6 +943,7 @@
 	MR_Word				arity;
 	MR_Word				atom;
 	int				hv;   /* any head variable */
+	int				num_added_args;
 	MR_TypeInfoParams		type_params;
 	const MR_Proc_Layout		*entry = layout->MR_sll_entry;
 
@@ -965,6 +964,9 @@
 				(MR_Word) entry->MR_sle_num_head_vars);
 	);
 
+	/* Find out how many type-info/typeclass-info variables were added. */
+	num_added_args = entry->MR_sle_num_head_vars - arity;
+
 	for (hv = 0; hv < entry->MR_sle_num_head_vars; hv++) {
 		int		hlds_num;
 		MR_Word		arg;
@@ -975,8 +977,8 @@
 
 		hlds_num = entry->MR_sle_head_var_nums[hv];
 
-		is_prog_visible_headvar = 
-			MR_hlds_var_is_head_var(entry, hlds_num);
+		is_prog_visible_headvar =
+				hv >= num_added_args ? MR_TRUE : MR_FALSE;
 
 		problem = MR_trace_return_hlds_var_info(hlds_num, &arg_type,
 				&arg_value);
@@ -1002,35 +1004,6 @@
 	}
 
 	return atom;
-}
-
-static MR_bool
-MR_hlds_var_is_head_var(const MR_Proc_Layout *entry, int hlds_num)
-{
-	MR_ConstString	var_name;
-	MR_ConstString	prefix;
-	const char	*s;
-
-	var_name = MR_hlds_var_name(entry, hlds_num);
-	if (var_name == NULL) {
-		return MR_FALSE;
-	}
-
-	prefix = "HeadVar__";
-	if (! MR_strneq(var_name, prefix, strlen(prefix))) {
-		return MR_FALSE;
-	}
-
-	s = var_name + strlen(prefix);
-	while (*s != '\0') {
-		if (! MR_isdigit(*s)) {
-			return MR_FALSE;
-		}
-
-		s++;
-	}
-
-	return MR_TRUE;
 }
 
 static	MR_ConstString
Index: trace/mercury_trace_vars.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_vars.c,v
retrieving revision 1.43
diff -u -u -r1.43 mercury_trace_vars.c
--- trace/mercury_trace_vars.c	15 May 2002 11:24:21 -0000	1.43
+++ trace/mercury_trace_vars.c	5 Jun 2002 15:17:04 -0000
@@ -38,8 +38,12 @@
 ** as the fullname field, and the has_suffix field will be set to false
 ** (the num_suffix field will not contain anything meaningful).
 **
-** The is_headvar field will be set to true iff the basename of the variable
-** is HeadVar__; such variables are always listed before other variables.
+** If the variable is an argument (but not a type-info argument), the
+** is_headvar field is set to the argument number (starting at 1).
+** If the variable is not an argument, the is_headvar field will be 0.
+** This field is used to list the head variables in order before the
+** body variables.
+**
 ** The is_ambiguous field will be set iff the full name of the variable
 ** does not uniquely identify it among all the variables live at the
 ** current point. What *is* guaranteed to uniquely identify a variable
@@ -54,7 +58,7 @@
 	char				*MR_var_basename;
 	int				MR_var_num_suffix;
 	MR_bool				MR_var_has_suffix;
-	MR_bool				MR_var_is_headvar;
+	int				MR_var_is_headvar;
 	MR_bool				MR_var_is_ambiguous;
 	int				MR_var_hlds_number;
 	MR_TypeInfo			MR_var_type;
@@ -308,6 +312,8 @@
 	const MR_Proc_Layout		*entry;
 	MR_Word				*valid_saved_regs;
 	int				var_count;
+	int				proc_arity;
+	int				num_added_args;
 	MR_TypeInfo			*type_params;
 	MR_Word				value;
 	MR_TypeInfo			type_info;
@@ -400,9 +406,18 @@
 	string_table_size =
 		entry->MR_sle_module_layout->MR_ml_string_table_size;
 
+	/* Work out how many type-infos were added. */
+	if (MR_PROC_LAYOUT_COMPILER_GENERATED(entry)) {
+		proc_arity = entry->MR_sle_comp.MR_comp_arity;
+	} else {
+		proc_arity = entry->MR_sle_user.MR_user_arity;
+	}
+	num_added_args = entry->MR_sle_num_head_vars - proc_arity;
+
 	slot = 0;
 	for (i = 0; i < var_count; i++) {
 		int	var_num;
+		int	head_var_num;
 		int	offset;
 
 		var_num = level_layout->MR_sll_var_nums[i];
@@ -479,14 +494,18 @@
 			MR_point.MR_point_vars[slot].MR_var_basename = copy;
 		}
 
-		if (MR_streq(MR_point.MR_point_vars[slot].MR_var_basename,
-			"HeadVar__"))
+		MR_point.MR_point_vars[slot].MR_var_is_headvar = 0;
+		for (head_var_num = num_added_args;
+				head_var_num < entry->MR_sle_num_head_vars;
+				head_var_num++)
 		{
-			MR_point.MR_point_vars[slot].MR_var_is_headvar =
-						MR_TRUE;
-		} else {
-			MR_point.MR_point_vars[slot].MR_var_is_headvar =
-						MR_FALSE;
+			if (entry->MR_sle_head_var_nums[head_var_num]
+					== var_num)
+			{
+				MR_point.MR_point_vars[slot].MR_var_is_headvar
+					= head_var_num - num_added_args + 1;
+				break;
+			}
 		}
 
 		MR_point.MR_point_vars[slot].MR_var_is_ambiguous = MR_FALSE;
@@ -554,14 +573,20 @@
 {
 	MR_Var_Details	*var1;
 	MR_Var_Details	*var2;
+	int		var1_is_headvar;
+	int		var2_is_headvar;
 	int		diff;
 
 	var1 = (MR_Var_Details *) arg1;
 	var2 = (MR_Var_Details *) arg2;
 
-	if (var1->MR_var_is_headvar && ! var2->MR_var_is_headvar) {
+	var1_is_headvar = var1->MR_var_is_headvar;
+	var2_is_headvar = var2->MR_var_is_headvar;
+	if (var1_is_headvar && var2_is_headvar) {
+		return var1_is_headvar - var2_is_headvar;
+	} else if (var1_is_headvar && ! var2_is_headvar) {
 		return -1;
-	} else if (! var1->MR_var_is_headvar && var2->MR_var_is_headvar) {
+	} else if (! var1_is_headvar && var2_is_headvar) {
 		return 1;
 	}
 
@@ -752,41 +777,76 @@
 	MR_ConstString		proc_name;
 	MR_Word			is_func;
 	MR_Word			arg_list;
+	MR_Word			prev;
+	MR_Word			cur;
 	MR_Word			arg;
 	MR_TypeInfo		arg_list_typeinfo;
 	MR_Var_Details		*vars;
+	int			headvar_num;
 	int			arity;
-	int			hv;
 	int			slot;
 
-	proc_layout = MR_point.MR_point_level_entry;
-	MR_generate_proc_name_from_layout(proc_layout, &proc_name, &arity,
-		&is_func);
-
-	vars = MR_point.MR_point_vars;
-	for (slot = MR_point.MR_point_var_count - 1; slot >= 0; slot--) {
-		if (vars[slot].MR_var_is_headvar) {
-			break;
-		}
-	}
-
-	arg_list = MR_list_empty();
-	for (hv = arity; hv >= 1; hv--) {
-		if (slot >= 0 && vars[slot].MR_var_is_headvar
-			&& vars[slot].MR_var_num_suffix == hv)
-		{
-			MR_new_univ_on_hp(arg, vars[slot].MR_var_type,
-				vars[slot].MR_var_value);
-			slot--;
-		} else {
-			MR_new_univ_on_hp(arg, &MR_unbound_typeinfo_struct,
-				MR_UNBOUND);
-		}
-		arg_list = MR_list_cons(arg, arg_list);
-	}
+        proc_layout = MR_point.MR_point_level_entry;
+        MR_generate_proc_name_from_layout(proc_layout, &proc_name, &arity,
+                &is_func);
+
+        vars = MR_point.MR_point_vars;
+        arg_list = MR_list_empty();
+        for (slot = MR_point.MR_point_var_count - 1; slot >= 0; slot--) {
+            headvar_num = vars[slot].MR_var_is_headvar;
+            if (headvar_num) {
+                /*
+                ** Insert the slot into the list sorted by argument number.
+                */
+                prev = MR_list_empty();
+                cur = arg_list;
+                while (!MR_list_is_empty(cur) &&
+                       headvar_num < vars[MR_list_head(cur)].MR_var_is_headvar)
+                {
+                    prev = cur;
+                    cur = MR_list_tail(cur);
+                }
+                if (MR_list_is_empty(prev)) {
+                    arg_list = MR_list_cons(slot, cur);
+                } else {
+                    MR_list_tail(prev) = MR_list_cons(slot, cur);
+                }
+            }
+        }
+
+        /*
+        ** Replace the slot numbers in the argument list
+        ** with the argument values, adding entries for
+        ** any unbound arguments (they will be printed
+        ** as `_').
+        */
+        prev = MR_list_empty();
+        cur = arg_list;
+        for (headvar_num = 1; headvar_num <= arity; headvar_num++) {
+            if (!MR_list_is_empty(cur) && 
+                vars[MR_list_head(cur)].MR_var_is_headvar == headvar_num)
+            {
+                slot = MR_list_head(cur);
+                MR_new_univ_on_hp(arg, vars[slot].MR_var_type,
+                        vars[slot].MR_var_value);
+                MR_list_head(cur) = arg;
+                prev = cur;
+                cur = MR_list_tail(cur);
+            } else {
+                MR_new_univ_on_hp(arg, &MR_unbound_typeinfo_struct,
+                        MR_UNBOUND);
+                if (MR_list_is_empty(prev)) {
+                        arg_list = MR_list_cons(arg, cur);
+                        prev = arg_list;
+                } else {
+                        MR_list_tail(prev) = MR_list_cons(arg, cur);
+                        prev = MR_list_tail(prev);
+                }
+            }
+        }
 
-	(*browser)(proc_name, arg_list, is_func, caller, format);
-	return NULL;
+        (*browser)(proc_name, arg_list, is_func, caller, format);
+        return NULL;
 }
 
 const char *
@@ -1173,6 +1233,19 @@
 		char	buf[256]; /* this should be plenty big enough */
 
 		sprintf(buf, "(%d)", var->MR_var_hlds_number);
+		len += strlen(buf);
+		fputs(buf, out);
+	}
+
+	/*
+	** If the variable starts with "HeadVar__" then the
+	** argument number is part of the name.
+	*/
+	if (var->MR_var_is_headvar &&
+			!MR_streq(var->MR_var_basename, "HeadVar__")) {
+		char	buf[256]; /* this should be plenty big enough */
+
+		sprintf(buf, " (arg %d)", var->MR_var_is_headvar);
 		len += strlen(buf);
 		fputs(buf, out);
 	}
--------------------------------------------------------------------------
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