[m-rev.] diff: change arg ordering in varset module

Julien Fischer juliensf at csse.unimelb.edu.au
Thu May 5 13:55:07 AEST 2011


Branches: main

Change the argument order of predicates in the varset module to make
them more conducive to the use of state variable notation.

library/varset.m:
 	As above.

library/parser.m:
library/term_io.m:
library/svvarset.m:
compiler/*.m:
samples/interpreter.m:
tests/debugger/interpreter.m:
tests/general/interpreter.m:
tests/hard_coded/bigtest.m:
tests/hard_coded/deep_copy_bug.m:
tests/hard_coded/lp.m:
tests/hard_coded/pprint_test.m:
tests/hard_coded/type_spec_ho_term.m:
 	Conform to the above change and remove dependencies on the svvarset
 	module.

Julien.

Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.83
diff -u -r1.83 accumulator.m
--- compiler/accumulator.m	3 May 2011 04:34:52 -0000	1.83
+++ compiler/accumulator.m	4 May 2011 11:42:13 -0000
@@ -1190,7 +1190,7 @@
  create_new_var(OldVar, Prefix, NewVar, !VarSet, !VarTypes) :-
      varset.lookup_name(!.VarSet, OldVar, OldName),
      string.append(Prefix, OldName, NewName),
-    varset.new_named_var(!.VarSet, NewName, NewVar, !:VarSet),
+    varset.new_named_var(NewName, NewVar, !VarSet),
      map.lookup(!.VarTypes, OldVar, Type),
      map.det_insert(NewVar, Type, !VarTypes).

Index: compiler/add_heap_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_heap_ops.m,v
retrieving revision 1.47
diff -u -r1.47 add_heap_ops.m
--- compiler/add_heap_ops.m	3 May 2011 04:34:52 -0000	1.47
+++ compiler/add_heap_ops.m	4 May 2011 11:36:42 -0000
@@ -352,10 +352,10 @@
  new_var(Name, Type, Var, !Info) :-
      VarSet0 = !.Info ^ heap_varset,
      VarTypes0 = !.Info ^ heap_var_types,
-    varset.new_named_var(VarSet0, Name, Var, VarSet),
+    varset.new_named_var(Name, Var, VarSet0, VarSet),
      map.det_insert(Var, Type, VarTypes0, VarTypes),
-    !:Info = !.Info ^ heap_varset := VarSet,
-    !:Info = !.Info ^ heap_var_types := VarTypes.
+    !Info ^ heap_varset := VarSet,
+    !Info ^ heap_var_types := VarTypes.

  %-----------------------------------------------------------------------------%

Index: compiler/add_pragma.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pragma.m,v
retrieving revision 1.112
diff -u -r1.112 add_pragma.m
--- compiler/add_pragma.m	3 May 2011 14:22:13 -0000	1.112
+++ compiler/add_pragma.m	4 May 2011 11:57:32 -0000
@@ -176,7 +176,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module varset.

  %-----------------------------------------------------------------------------%
@@ -2662,9 +2661,9 @@
          set_purity(purity_pure, !Attrs),
          set_may_duplicate(yes(proc_may_not_duplicate), !Attrs),
          varset.init(!:VarSet),
-        svvarset.new_named_var("Stats", Stats, !VarSet),
-        svvarset.new_named_var("IO0", IO0, !VarSet),
-        svvarset.new_named_var("IO", IO, !VarSet),
+        varset.new_named_var("Stats", Stats, !VarSet),
+        varset.new_named_var("IO0", IO0, !VarSet),
+        varset.new_named_var("IO", IO, !VarSet),
          Arg1 = pragma_var(Stats, "Stats", out_mode, always_boxed),
          Arg2 = pragma_var(IO0, "_IO0", di_mode, always_boxed),
          Arg3 = pragma_var(IO, "_IO", uo_mode, always_boxed),
@@ -2741,8 +2740,8 @@
          set_purity(purity_pure, !Attrs),
          set_may_duplicate(yes(proc_may_not_duplicate), !Attrs),
          varset.init(!:VarSet),
-        svvarset.new_named_var("IO0", IO0, !VarSet),
-        svvarset.new_named_var("IO", IO, !VarSet),
+        varset.new_named_var("IO0", IO0, !VarSet),
+        varset.new_named_var("IO", IO, !VarSet),
          Arg1 = pragma_var(IO0, "_IO0", di_mode, always_boxed),
          Arg2 = pragma_var(IO, "_IO", uo_mode, always_boxed),

@@ -3033,7 +3032,7 @@
          !Specs) :-
      map.lookup(ProcTable, ProcID, ProcInfo),
      varset.init(ProgVarSet0),
-    varset.new_vars(ProgVarSet0, Arity, Vars, ProgVarSet),
+    varset.new_vars(Arity, Vars, ProgVarSet0, ProgVarSet),
      proc_info_get_argmodes(ProcInfo, Modes),
      proc_info_get_inst_varset(ProcInfo, InstVarSet),
      fact_table_pragma_vars(Vars, Modes, ProgVarSet, PragmaVars),
Index: compiler/add_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_pred.m,v
retrieving revision 1.45
diff -u -r1.45 add_pred.m
--- compiler/add_pred.m	3 May 2011 04:34:52 -0000	1.45
+++ compiler/add_pred.m	4 May 2011 11:22:55 -0000
@@ -274,7 +274,7 @@
          Module = mercury_private_builtin_module,
          Name = "trace_get_io_state"
      ->
-        varset.new_var(VarSet0, ZeroVar, VarSet),
+        varset.new_var(ZeroVar, VarSet0, VarSet),
          ExtraVars = [ZeroVar],
          ExtraTypes = [int_type],

Index: compiler/add_solver.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_solver.m,v
retrieving revision 1.23
diff -u -r1.23 add_solver.m
--- compiler/add_solver.m	25 Sep 2009 05:13:01 -0000	1.23
+++ compiler/add_solver.m	4 May 2011 11:24:10 -0000
@@ -194,8 +194,8 @@
      OutGroundMode     = out_mode(GroundInst),

      ProgVarSet0       = varset.init,
-    varset.new_var(ProgVarSet0, X, ProgVarSet1),
-    varset.new_var(ProgVarSet1, Y, ProgVarSet),
+    varset.new_var(X, ProgVarSet0, ProgVarSet1),
+    varset.new_var(Y, ProgVarSet1, ProgVarSet),

      InstVarSet = varset.init,

Index: compiler/add_trail_ops.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/add_trail_ops.m,v
retrieving revision 1.58
diff -u -r1.58 add_trail_ops.m
--- compiler/add_trail_ops.m	3 May 2011 04:34:52 -0000	1.58
+++ compiler/add_trail_ops.m	4 May 2011 11:37:16 -0000
@@ -607,10 +607,10 @@
  new_var(Name, Type, Var, !Info) :-
      VarSet0 = !.Info ^ trail_varset,
      VarTypes0 = !.Info ^ trail_var_types,
-    varset.new_named_var(VarSet0, Name, Var, VarSet),
+    varset.new_named_var(Name, Var, VarSet0, VarSet),
      map.det_insert(Var, Type, VarTypes0, VarTypes),
-    !:Info = !.Info ^ trail_varset := VarSet,
-    !:Info = !.Info ^ trail_var_types := VarTypes.
+    !Info ^ trail_varset := VarSet,
+    !Info ^ trail_var_types := VarTypes.

  %-----------------------------------------------------------------------------%

Index: compiler/build_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/build_mode_constraints.m,v
retrieving revision 1.42
diff -u -r1.42 build_mode_constraints.m
--- compiler/build_mode_constraints.m	3 May 2011 04:34:53 -0000	1.42
+++ compiler/build_mode_constraints.m	4 May 2011 11:57:45 -0000
@@ -201,7 +201,6 @@
  :- import_module multi_map.
  :- import_module require.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -1029,7 +1028,7 @@
          true
      ;
          MCVarName = rep_var_to_string(ProgVarset, RepVar),
-        svvarset.new_named_var(MCVarName, NewMCVar, !Varset),
+        varset.new_named_var(MCVarName, NewMCVar, !Varset),
          bimap.det_insert(RepVar, NewMCVar, !VarMap)
      ).

Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.88
diff -u -r1.88 clause_to_proc.m
--- compiler/clause_to_proc.m	3 May 2011 04:34:53 -0000	1.88
+++ compiler/clause_to_proc.m	4 May 2011 11:57:57 -0000
@@ -87,7 +87,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -277,15 +276,14 @@

  :- func set_arg_names(foreign_arg, prog_varset) = prog_varset.

-set_arg_names(Arg, Vars0) = Vars :-
+set_arg_names(Arg, !.Vars) = !:Vars :-
      Var = foreign_arg_var(Arg),
      MaybeNameMode = foreign_arg_maybe_name_mode(Arg),
      (
          MaybeNameMode = yes(Name - _),
-        varset.name_var(Vars0, Var, Name, Vars)
+        varset.name_var(Var, Name, !Vars)
      ;
-        MaybeNameMode = no,
-        Vars = Vars0
+        MaybeNameMode = no
      ).

  :- pred select_matching_clauses(list(clause)::in, proc_id::in,
@@ -572,10 +570,10 @@
      prog_varset::in, prog_varset::out) is det.

  make_new_exist_cast_var(InternalVar, ExternalVar, !VarSet) :-
-    svvarset.new_var(ExternalVar, !VarSet),
+    varset.new_var(ExternalVar, !VarSet),
      varset.lookup_name(!.VarSet, InternalVar, InternalName),
      string.append("ExistQ", InternalName, ExternalName),
-    svvarset.name_var(ExternalVar, ExternalName, !VarSet).
+    varset.name_var(ExternalVar, ExternalName, !VarSet).

  %-----------------------------------------------------------------------------%

Index: compiler/complexity.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/complexity.m,v
retrieving revision 1.41
diff -u -r1.41 complexity.m
--- compiler/complexity.m	3 May 2011 04:34:53 -0000	1.41
+++ compiler/complexity.m	4 May 2011 11:42:40 -0000
@@ -480,7 +480,7 @@
  generate_new_var(Name, Type, !ProcInfo, Var) :-
      proc_info_get_varset(!.ProcInfo, VarSet0),
      proc_info_get_vartypes(!.ProcInfo, VarTypes0),
-    varset.new_named_var(VarSet0, Name, Var, VarSet),
+    varset.new_named_var(Name, Var, VarSet0, VarSet),
      map.set(Var, Type, VarTypes0, VarTypes),
      proc_info_set_varset(VarSet, !ProcInfo),
      proc_info_set_vartypes(VarTypes, !ProcInfo).
Index: compiler/constraint.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/constraint.m,v
retrieving revision 1.98
diff -u -r1.98 constraint.m
--- compiler/constraint.m	3 May 2011 04:34:53 -0000	1.98
+++ compiler/constraint.m	4 May 2011 11:43:26 -0000
@@ -562,7 +562,7 @@
      ->
          VarSet0 = !.Info ^ constr_varset,
          VarTypes0 = !.Info ^ constr_vartypes,
-        varset.new_var(VarSet0, NewVar, VarSet),
+        varset.new_var(NewVar, VarSet0, VarSet),
          map.lookup(VarTypes0, ConstructVar, VarType),
          map.det_insert(NewVar, VarType, VarTypes0, VarTypes),
          !Info ^ constr_varset := VarSet,
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.130
diff -u -r1.130 cse_detection.m
--- compiler/cse_detection.m	3 May 2011 04:34:53 -0000	1.130
+++ compiler/cse_detection.m	4 May 2011 07:30:02 -0000
@@ -709,7 +709,7 @@
          Goal) :-
      VarSet0 = !.CseInfo ^ csei_varset,
      VarTypes0 = !.CseInfo ^ csei_vartypes,
-    varset.new_var(VarSet0, NFV, VarSet),
+    varset.new_var( NFV, VarSet0, VarSet),
      map.lookup(VarTypes0, OFV, Type),
      map.det_insert(NFV, Type, VarTypes0, VarTypes),
      !:OldNewVar = [OFV - NFV | !.OldNewVar],
Index: compiler/deep_profiling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deep_profiling.m,v
retrieving revision 1.111
diff -u -r1.111 deep_profiling.m
--- compiler/deep_profiling.m	3 May 2011 04:34:53 -0000	1.111
+++ compiler/deep_profiling.m	4 May 2011 11:58:09 -0000
@@ -81,7 +81,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -1741,7 +1740,7 @@
      prog_varset::in, prog_varset::out, vartypes::in, vartypes::out) is det.

  generate_var_2(Name, Type, Var, !VarSet, !VarTypes) :-
-    svvarset.new_named_var(Name, Var, !VarSet),
+    varset.new_named_var(Name, Var, !VarSet),
      map.det_insert(Var, Type, !VarTypes).

  :- pred maybe_generate_activation_ptr(bool::in, prog_var::in, prog_var::in,
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.98
diff -u -r1.98 deforest.m
--- compiler/deforest.m	3 May 2011 04:34:53 -0000	1.98
+++ compiler/deforest.m	4 May 2011 11:43:48 -0000
@@ -1352,7 +1352,7 @@
          Arg = Arg0
      ;
          % The variable is local to the call. Create a fresh variable.
-        varset.new_var(!.VarSet, Arg, !:VarSet),
+        varset.new_var(Arg, !VarSet),
          apply_subst_to_type(TypeSubn, ArgType, SubnArgType),
          map.det_insert(Arg, SubnArgType, !VarTypes)
      ),
Index: compiler/dep_par_conj.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/dep_par_conj.m,v
retrieving revision 1.49
diff -u -r1.49 dep_par_conj.m
--- compiler/dep_par_conj.m	3 May 2011 04:34:53 -0000	1.49
+++ compiler/dep_par_conj.m	4 May 2011 11:58:40 -0000
@@ -169,7 +169,6 @@
  :- import_module require.
  :- import_module std_util.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -3043,7 +3042,7 @@
          FutureVar, FutureVarType) :-
      FutureVarType = future_type(SharedVarType),
      varset.lookup_name(!.VarSet, SharedVar, SharedVarName),
-    svvarset.new_named_var("Future" ++ SharedVarName, FutureVar, !VarSet),
+    varset.new_named_var("Future" ++ SharedVarName, FutureVar, !VarSet),
      map.det_insert(FutureVar, FutureVarType, !VarTypes).

  :- pred make_wait_goal(module_info::in, vartypes::in,
Index: compiler/erl_code_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_gen.m,v
retrieving revision 1.37
diff -u -r1.37 erl_code_gen.m
--- compiler/erl_code_gen.m	29 Dec 2010 04:52:17 -0000	1.37
+++ compiler/erl_code_gen.m	4 May 2011 11:07:45 -0000
@@ -1576,7 +1576,7 @@
          Arity = elds_body_arity(TargetBody),

          % ``Name(Vars, ...) -> PredProcId(Vars, ...)''
-        varset.new_vars(varset.init, Arity, Vars, VarSet),
+        varset.new_vars(Arity, Vars, varset.init, VarSet),
          Clause = elds_clause(terms_from_vars(Vars),
              elds_call(elds_call_plain(PredProcId), exprs_from_vars(Vars))),
          ForeignExportDefn = elds_foreign_export_defn(Name, VarSet, Clause)
Index: compiler/erl_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_code_util.m,v
retrieving revision 1.22
diff -u -r1.22 erl_code_util.m
--- compiler/erl_code_util.m	3 May 2011 04:34:54 -0000	1.22
+++ compiler/erl_code_util.m	4 May 2011 11:10:57 -0000
@@ -283,12 +283,12 @@

  erl_gen_info_new_named_var(Name, NewVar, !Info) :-
      erl_gen_info_get_varset(!.Info, VarSet0),
-    varset.new_named_var(VarSet0, Name, NewVar, VarSet),
+    varset.new_named_var(Name, NewVar, VarSet0, VarSet),
      erl_gen_info_set_varset(VarSet, !Info).

  erl_gen_info_new_vars(Num, NewVars, !Info) :-
      erl_gen_info_get_varset(!.Info, VarSet0),
-    varset.new_vars(VarSet0, Num, NewVars, VarSet),
+    varset.new_vars(Num, NewVars, VarSet0, VarSet),
      erl_gen_info_set_varset(VarSet, !Info).

  erl_gen_info_new_anonymous_vars(Num, NewVars, !Info) :-
@@ -300,8 +300,8 @@
  :- pred erl_gen_info_new_anonymous_var(int::in, prog_var::out,
      prog_varset::in, prog_varset::out) is det.

-erl_gen_info_new_anonymous_var(_Num, NewVar, VarSet0, VarSet) :-
-    varset.new_named_var(VarSet0, "_", NewVar, VarSet).
+erl_gen_info_new_anonymous_var(_Num, NewVar, !VarSet) :-
+    varset.new_named_var("_", NewVar, !VarSet).

  erl_variable_types(Info, Vars, Types) :-
      list.map(erl_variable_type(Info), Vars, Types).
@@ -541,11 +541,11 @@
  :- pred erl_create_renaming_2(prog_var::in, prog_varset::in, prog_varset::out,
      prog_var_renaming::in, prog_var_renaming::out) is det.

-erl_create_renaming_2(OldVar, VarSet0, VarSet, !Subst) :-
-    ( varset.search_name(VarSet0, OldVar, Name) ->
-        varset.new_named_var(VarSet0, Name, NewVar, VarSet)
+erl_create_renaming_2(OldVar, !VarSet, !Subst) :-
+    ( varset.search_name(!.VarSet, OldVar, Name) ->
+        varset.new_named_var(Name, NewVar, !VarSet)
      ;
-        varset.new_var(VarSet0, NewVar, VarSet)
+        varset.new_var(NewVar, !VarSet)
      ),
      map.det_insert(OldVar, NewVar, !Subst).

Index: compiler/erl_rtti.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/erl_rtti.m,v
retrieving revision 1.23
diff -u -r1.23 erl_rtti.m
--- compiler/erl_rtti.m	30 Dec 2010 11:17:53 -0000	1.23
+++ compiler/erl_rtti.m	4 May 2011 11:58:59 -0000
@@ -57,7 +57,6 @@
  :- import_module int.
  :- import_module maybe.
  :- import_module require.
-:- import_module svvarset.
  :- import_module univ.
  :- import_module varset.

@@ -314,8 +313,8 @@
      %       {Y1, Y2, ...}   /* may have additional outputs */
      %   end

-    svvarset.new_named_var("TypeClassInfo", TCIVar, !VarSet),
-    svvarset.new_vars(list.length(ArgTypes) - NumExtra, Ws, !VarSet),
+    varset.new_named_var("TypeClassInfo", TCIVar, !VarSet),
+    varset.new_vars(list.length(ArgTypes) - NumExtra, Ws, !VarSet),

      % Make the ``E<n> = element(<n>, TypeClassInfo)'' expressions.
      list.map2_foldl(extract_extra_arg(TCIVar), 1 .. NumExtra,
@@ -353,7 +352,7 @@
          % model_non wrappers need an additional argument which is the success
          % continuation.  On success we call the success continuation with the
          % output arguments of the call.
-        svvarset.new_named_var("Succeed", SucceedVar, !VarSet),
+        varset.new_named_var("Succeed", SucceedVar, !VarSet),
          AllWrapperInputVars = [TCIVar | WrapperInputVars] ++ [SucceedVar],
          SuccessExpr0 = elds_call(elds_call_ho(expr_from_var(SucceedVar)),
              WrapperOutputVarsExprs)
@@ -378,7 +377,7 @@
      prog_varset::in, prog_varset::out) is det.

  extract_extra_arg(TCIVar, Index, Var, ExtractStatement, !VarSet) :-
-    svvarset.new_named_var("Extra", Var, !VarSet),
+    varset.new_named_var("Extra", Var, !VarSet),
      % Erlang's `element' builtin counts from 1.
      ExtractStatement = elds_eq(expr_from_var(Var),
          elds_call_element(TCIVar, 1 + Index)).
@@ -672,7 +671,7 @@
      Detism = RttiProcLabel ^ rpl_proc_interface_detism,

      % Create the variable list.
-    svvarset.new_vars(list.length(ArgTypes), Ws, !VarSet),
+    varset.new_vars(list.length(ArgTypes), Ws, !VarSet),

      % Figure out the input and output variables for the call to the actual
      % special pred implementation.
@@ -772,7 +771,7 @@
          unqualify_name(SymName) = "[|]"
      ->
          reduce_list_term_complexity(Tail0, Tail, !RevAssignments, !VarSet),
-        svvarset.new_var(V, !VarSet),
+        varset.new_var(V, !VarSet),
          Assign = elds_eq(expr_from_var(V), Tail),
          Expr = elds_term(elds_tuple([Functor, Head, expr_from_var(V)])),
          list.cons(Assign, !RevAssignments)
Index: compiler/field_access.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/field_access.m,v
retrieving revision 1.19
diff -u -r1.19 field_access.m
--- compiler/field_access.m	7 Mar 2011 03:59:23 -0000	1.19
+++ compiler/field_access.m	4 May 2011 11:25:28 -0000
@@ -151,8 +151,8 @@
      make_fresh_arg_vars(FieldArgs, FieldArgVars, !VarSet, !SVarState, !Specs),
      (
          FieldNames = [_ | _],
-        varset.new_var(!.VarSet, SubTermInputVar, !:VarSet),
-        varset.new_var(!.VarSet, SubTermOutputVar, !:VarSet),
+        varset.new_var(SubTermInputVar, !VarSet),
+        varset.new_var(SubTermOutputVar, !VarSet),
          SetArgs = FieldArgVars ++ [TermInputVar, SubTermOutputVar],
          construct_field_access_function_call(set, Context,
              MainContext, SubContext0, FieldName, TermOutputVar,
@@ -248,7 +248,7 @@
      GetArgVars = FieldArgVars ++ [TermInputVar],
      (
          FieldNames = [_ | _],
-        varset.new_var(!.VarSet, SubTermInputVar, !:VarSet),
+        varset.new_var(SubTermInputVar, !VarSet),
          construct_field_access_function_call(get, Context, MainContext,
              SubContext0, FieldName, SubTermInputVar, GetArgVars, Purity,
              Functor, Goal, !QualInfo),
Index: compiler/format_call.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/format_call.m,v
retrieving revision 1.25
diff -u -r1.25 format_call.m
--- compiler/format_call.m	3 May 2011 04:34:54 -0000	1.25
+++ compiler/format_call.m	4 May 2011 12:03:21 -0000
@@ -158,9 +158,9 @@
  :- import_module set.
  :- import_module set_tree234.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module univ.
+:- import_module varset.

  %-----------------------------------------------------------------------------%

@@ -1320,7 +1320,7 @@
          MaybeResultVar = yes(ResultVar)
      ;
          MaybeResultVar = no,
-        svvarset.new_var(ResultVar, !VarSet),
+        varset.new_var(ResultVar, !VarSet),
          map.det_insert(ResultVar, string_type, !VarTypes)
      ).

Index: compiler/goal_expr_to_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_expr_to_goal.m,v
retrieving revision 1.1
diff -u -r1.1 goal_expr_to_goal.m
--- compiler/goal_expr_to_goal.m	7 Mar 2011 03:59:23 -0000	1.1
+++ compiler/goal_expr_to_goal.m	4 May 2011 11:27:18 -0000
@@ -981,8 +981,8 @@
  transform_try_expr_with_io(LocKind, IOStateVarUnrenamed, IOStateVar, Goal0,
          Then0, Catches0, MaybeCatchAny0, Context, Renaming, TryGoal, NumAdded,
          !SVarState, !SVarStore, !VarSet, !ModuleInfo, !QualInfo, !Specs) :-
-    varset.new_named_var(!.VarSet, "TryResult", ResultVar, !:VarSet),
-    varset.new_var(!.VarSet, ExcpVar, !:VarSet),
+    varset.new_named_var("TryResult", ResultVar, !VarSet),
+    varset.new_var(ExcpVar, !VarSet),

      ResultVarTerm = variable(ResultVar, Context),
      ExcpVarTerm = variable(ExcpVar, Context),
@@ -1123,8 +1123,8 @@
  transform_try_expr_without_io(LocKind, Goal0, Then0, MaybeElse0, Catches0,
          MaybeCatchAny0, Context, Renaming, TryGoal, NumAdded,
          !SVarState, !SVarStore, !VarSet, !ModuleInfo, !QualInfo, !Specs) :-
-    varset.new_named_var(!.VarSet, "TryResult", ResultVar, !:VarSet),
-    varset.new_var(!.VarSet, ExcpVar, !:VarSet),
+    varset.new_named_var("TryResult", ResultVar, !VarSet),
+    varset.new_var(ExcpVar, !VarSet),

      ResultVarTerm = variable(ResultVar, Context),
      ExcpVarTerm = variable(ExcpVar, Context),
Index: compiler/goal_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/goal_util.m,v
retrieving revision 1.182
diff -u -r1.182 goal_util.m
--- compiler/goal_util.m	3 May 2011 04:34:54 -0000	1.182
+++ compiler/goal_util.m	4 May 2011 11:59:47 -0000
@@ -454,7 +454,6 @@
  :- import_module solutions.
  :- import_module string.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module varset.

  %-----------------------------------------------------------------------------%
@@ -482,7 +481,7 @@
          !Renaming).
  create_renaming_2([OrigVar | OrigVars], InstMapDelta, !VarSet, !VarTypes,
          !RevUnifies, !RevNewVars, !Renaming) :-
-    svvarset.new_var(NewVar, !VarSet),
+    varset.new_var(NewVar, !VarSet),
      map.lookup(!.VarTypes, OrigVar, Type),
      map.det_insert(NewVar, Type, !VarTypes),
      ( instmap_delta_search_var(InstMapDelta, OrigVar, DeltaInst) ->
@@ -512,9 +511,9 @@
      ( map.search(!.Renaming, Var, CloneVarPrime) ->
          CloneVar = CloneVarPrime
      ;
-        svvarset.new_var(CloneVar, !VarSet),
+        varset.new_var(CloneVar, !VarSet),
          ( varset.search_name(OldVarNames, Var, Name) ->
-            svvarset.name_var(CloneVar, Name, !VarSet)
+            varset.name_var(CloneVar, Name, !VarSet)
          ;
              true
          ),
@@ -1345,7 +1344,7 @@
  case_to_disjunct(Var, CaseGoal, InstMap, ConsId, Disjunct, !VarSet, !VarTypes,
          !ModuleInfo) :-
      ConsArity = cons_id_arity(ConsId),
-    svvarset.new_vars(ConsArity, ArgVars, !VarSet),
+    varset.new_vars(ConsArity, ArgVars, !VarSet),
      map.lookup(!.VarTypes, Var, VarType),
      type_util.get_cons_id_arg_types(!.ModuleInfo, VarType, ConsId, ArgTypes),
      map.det_insert_from_corresponding_lists(ArgVars, ArgTypes, !VarTypes),
Index: compiler/headvar_names.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/headvar_names.m,v
retrieving revision 1.10
diff -u -r1.10 headvar_names.m
--- compiler/headvar_names.m	3 May 2011 04:34:54 -0000	1.10
+++ compiler/headvar_names.m	4 May 2011 11:59:54 -0000
@@ -46,7 +46,6 @@
  :- import_module set.
  :- import_module varset.
  :- import_module svset.
-:- import_module svvarset.

  maybe_improve_headvar_names(Globals, !PredInfo) :-
      globals.lookup_bool_option(Globals, make_optimization_interface, MakeOpt),
@@ -165,7 +164,7 @@
                  \+ varset.search_name(!.VarSet, OtherVar, _),
                  varset.search_name(!.VarSet, HeadVar, HeadVarName)
              ->
-                svvarset.name_var(OtherVar, HeadVarName, !VarSet)
+                varset.name_var(OtherVar, HeadVarName, !VarSet)
              ;
                  true
              )
@@ -175,10 +174,10 @@
              ( varset.search_name(!.VarSet, OtherVar, OtherVarName) ->
                  % The unification can't be eliminated,
                  % so just rename the head variable.
-                svvarset.name_var(HeadVar, OtherVarName, !VarSet)
+                varset.name_var(HeadVar, OtherVarName, !VarSet)
              ; varset.search_name(!.VarSet, HeadVar, HeadVarName) ->
                  % If the variable wasn't named, use the `HeadVar__n' name.
-                svvarset.name_var(OtherVar, HeadVarName, !VarSet)
+                varset.name_var(OtherVar, HeadVarName, !VarSet)
              ;
                  true
              )
Index: compiler/hhf.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hhf.m,v
retrieving revision 1.44
diff -u -r1.44 hhf.m
--- compiler/hhf.m	3 May 2011 04:34:54 -0000	1.44
+++ compiler/hhf.m	4 May 2011 11:11:48 -0000
@@ -366,7 +366,7 @@
      ->
          VarSet0 = !.HI ^ hhfi_varset,
          VarTypes0 = !.HI ^ hhfi_vartypes,
-        varset.new_var(VarSet0, V, VarSet),
+        varset.new_var(V, VarSet0, VarSet),
          map.lookup(VarTypes0, A, Type),
          map.det_insert(V, Type, VarTypes0, VarTypes),
          map.init(Empty),
@@ -450,7 +450,7 @@
      ->
          NewVar = NewVar0
      ;
-        varset.new_var(VarSet0, NewVar, VarSet),
+        varset.new_var(NewVar, VarSet0, VarSet),
          map.det_insert(NewVar, ArgType, VarTypes0, VarTypes),
          map.init(Empty),
          map.det_insert(NewVar, node(Empty, parent(Var)),
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.223
diff -u -r1.223 hlds_goal.m
--- compiler/hlds_goal.m	3 May 2011 04:34:54 -0000	1.223
+++ compiler/hlds_goal.m	4 May 2011 12:00:02 -0000
@@ -1822,7 +1822,6 @@
  :- import_module map.
  :- import_module require.
  :- import_module string.
-:- import_module svvarset.
  :- import_module varset.

  %-----------------------------------------------------------------------------%
@@ -3532,31 +3531,31 @@

  make_int_const_construction_alloc(Int, MaybeName, Goal, Var,
          !VarSet, !VarTypes) :-
-    svvarset.new_maybe_named_var(MaybeName, Var, !VarSet),
+    varset.new_maybe_named_var(MaybeName, Var, !VarSet),
      map.det_insert(Var, int_type, !VarTypes),
      make_int_const_construction(Var, Int, Goal).

  make_string_const_construction_alloc(String, MaybeName, Goal, Var,
          !VarSet, !VarTypes) :-
-    svvarset.new_maybe_named_var(MaybeName, Var, !VarSet),
+    varset.new_maybe_named_var(MaybeName, Var, !VarSet),
      map.det_insert(Var, string_type, !VarTypes),
      make_string_const_construction(Var, String, Goal).

  make_float_const_construction_alloc(Float, MaybeName, Goal, Var,
          !VarSet, !VarTypes) :-
-    svvarset.new_maybe_named_var(MaybeName, Var, !VarSet),
+    varset.new_maybe_named_var(MaybeName, Var, !VarSet),
      map.det_insert(Var, float_type, !VarTypes),
      make_float_const_construction(Var, Float, Goal).

  make_char_const_construction_alloc(Char, MaybeName, Goal, Var,
          !VarSet, !VarTypes) :-
-    svvarset.new_maybe_named_var(MaybeName, Var, !VarSet),
+    varset.new_maybe_named_var(MaybeName, Var, !VarSet),
      map.det_insert(Var, char_type, !VarTypes),
      make_char_const_construction(Var, Char, Goal).

  make_const_construction_alloc(ConsId, Type, MaybeName, Goal, Var,
          !VarSet, !VarTypes) :-
-    svvarset.new_maybe_named_var(MaybeName, Var, !VarSet),
+    varset.new_maybe_named_var(MaybeName, Var, !VarSet),
      map.det_insert(Var, Type, !VarTypes),
      make_const_construction(Var, ConsId, Goal).

Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.268
diff -u -r1.268 hlds_pred.m
--- compiler/hlds_pred.m	3 May 2011 04:34:54 -0000	1.268
+++ compiler/hlds_pred.m	4 May 2011 11:14:31 -0000
@@ -1208,7 +1208,7 @@
      goal_util.goal_vars(Goal0, GoalVars0),
      set.insert_list(GoalVars0, ArgVars, GoalVars),
      map.select(VarTypes0, GoalVars, VarTypes),
-    varset.select(VarSet0, GoalVars, VarSet),
+    varset.select(GoalVars, VarSet0, VarSet),

      % Approximate the termination information for the new procedure.
      ( goal_cannot_loop(ModuleInfo0, Goal0) ->
@@ -2841,7 +2841,7 @@
  proc_info_create_var_from_type(Type, MaybeName, NewVar, !ProcInfo) :-
      proc_info_get_varset(!.ProcInfo, VarSet0),
      proc_info_get_vartypes(!.ProcInfo, VarTypes0),
-    varset.new_maybe_named_var(VarSet0, MaybeName, NewVar, VarSet),
+    varset.new_maybe_named_var(MaybeName, NewVar, VarSet0, VarSet),
      map.det_insert(NewVar, Type, VarTypes0, VarTypes),
      proc_info_set_varset(VarSet, !ProcInfo),
      proc_info_set_vartypes(VarTypes, !ProcInfo).
@@ -2850,7 +2850,7 @@
      list.length(Types, NumVars),
      proc_info_get_varset(!.ProcInfo, VarSet0),
      proc_info_get_vartypes(!.ProcInfo, VarTypes0),
-    varset.new_vars(VarSet0, NumVars, NewVars, VarSet),
+    varset.new_vars(NumVars, NewVars, VarSet0, VarSet),
      map.det_insert_from_corresponding_lists(NewVars, Types,
          VarTypes0, VarTypes),
      proc_info_set_varset(VarSet, !ProcInfo),
@@ -3043,7 +3043,7 @@
          true
      ;
          Name = "HeadVar__" ++ int_to_string(SeqNum),
-        varset.name_var(!.VarSet, Var, Name, !:VarSet)
+        varset.name_var(Var, Name, !VarSet)
      ),
      ensure_all_headvars_are_named_2(Vars, SeqNum + 1, !VarSet).

@@ -3196,7 +3196,7 @@
  is_inline_builtin(ModuleName, PredName, ProcId, Arity) :-
      Arity =< 3,
      prog_varset_init(VarSet),
-    varset.new_vars(VarSet, Arity, Args, _),
+    varset.new_vars(Arity, Args, VarSet, _),
      builtin_ops.translate_builtin(ModuleName, PredName, ProcId, Args, _).

  :- pred prog_varset_init(prog_varset::out) is det.
Index: compiler/hlds_statistics.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_statistics.m,v
retrieving revision 1.2
diff -u -r1.2 hlds_statistics.m
--- compiler/hlds_statistics.m	30 Jul 2010 05:16:11 -0000	1.2
+++ compiler/hlds_statistics.m	4 May 2011 11:21:13 -0000
@@ -421,7 +421,7 @@
      write_proc_stat_components(OutStream, Msg, Name, PredId, ProcId, Stats,
          !IO),

-    varset.new_var(VarSet, Var, _UpdatedVarSet),
+    varset.new_var(Var, VarSet, _UpdatedVarSet),
      term.var_to_int(Var, VarInt),
      NumUsedVars = set_tree234.count(UsedVars),
      io.format(OutStream, "VARS %d %d\n", [i(VarInt), i(NumUsedVars)], !IO).
Index: compiler/intermod.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/intermod.m,v
retrieving revision 1.260
diff -u -r1.260 intermod.m
--- compiler/intermod.m	3 May 2011 04:34:55 -0000	1.260
+++ compiler/intermod.m	4 May 2011 11:44:33 -0000
@@ -2038,7 +2038,7 @@
              MaybeNameAndMode = yes(Name - _Mode2)
          ),
          PragmaVar = pragma_var(Var, Name, Mode, native_if_possible),
-        varset.name_var(!.VarSet, Var, Name, !:VarSet),
+        varset.name_var(Var, Name, !VarSet),
          get_pragma_foreign_code_vars(ArgsTail, ModesTail, !VarSet,
              PragmaVarsTail),
          PragmaVars = [PragmaVar | PragmaVarsTail]
Index: compiler/interval.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/interval.m,v
retrieving revision 1.48
diff -u -r1.48 interval.m
--- compiler/interval.m	3 May 2011 04:34:55 -0000	1.48
+++ compiler/interval.m	4 May 2011 12:00:08 -0000
@@ -198,7 +198,6 @@
  :- import_module pair.
  :- import_module require.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -1108,7 +1107,7 @@
  create_shadow_var(Arg, VarsToExtract, !VarSet, !VarTypes,
          !VarRename, !VoidRename) :-
      varset.lookup_name(!.VarSet, Arg, Name),
-    svvarset.new_named_var(Name, Shadow, !VarSet),
+    varset.new_named_var(Name, Shadow, !VarSet),
      map.lookup(!.VarTypes, Arg, Type),
      map.det_insert(Shadow, Type, !VarTypes),
      ( set.member(Arg, VarsToExtract) ->
Index: compiler/lco.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lco.m,v
retrieving revision 1.66
diff -u -r1.66 lco.m
--- compiler/lco.m	3 May 2011 04:34:55 -0000	1.66
+++ compiler/lco.m	4 May 2011 12:00:15 -0000
@@ -203,7 +203,6 @@
  :- import_module set.
  :- import_module string.
  :- import_module svbag.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -877,7 +876,7 @@
      VarTypes0 = !.Info ^ lco_var_types,
      varset.lookup_name(VarSet0, Var, "SCCcallarg", Name),
      AddrName = "Addr" ++ Name,
-    varset.new_named_var(VarSet0, AddrName, AddrVar, VarSet),
+    varset.new_named_var(AddrName, AddrVar, VarSet0, VarSet),
      HighLevelData = ConstInfo ^ lci_highlevel_data,
      (
          HighLevelData = no,
@@ -1205,7 +1204,7 @@
          ->
              varset.lookup_name(!.VarSet, HeadVar0, Name),
              AddrName = "AddrOf" ++ Name,
-            svvarset.new_named_var(AddrName, AddrVar, !VarSet),
+            varset.new_named_var(AddrName, AddrVar, !VarSet),
              HeadVar = AddrVar,
              map.lookup(!.VarTypes, HeadVar0, OldType),
              (
Index: compiler/lp.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lp.m,v
retrieving revision 1.21
diff -u -r1.21 lp.m
--- compiler/lp.m	3 May 2011 04:34:55 -0000	1.21
+++ compiler/lp.m	4 May 2011 12:00:30 -0000
@@ -97,7 +97,6 @@
  :- import_module solutions.
  :- import_module string.
  :- import_module svset.
-:- import_module svvarset.

  %-----------------------------------------------------------------------------%

@@ -823,8 +822,8 @@
  lp_info_init(Varset0, URSVars, LPInfo) :-
      Introduce = (pred(Orig::in, VP0::in, VP::out) is det :-
          VP0 = VS0 - VM0,
-        varset.new_var(VS0, V1, VS1),
-        varset.new_var(VS1, V2, VS),
+        varset.new_var(V1, VS0, VS1),
+        varset.new_var(V2, VS1, VS),
          map.set(Orig, V1 - V2, VM0, VM),
          VP = VS - VM
      ),
@@ -837,7 +836,7 @@
  new_slack_var(Var, !Info) :-
      some [!Varset] (
          get_varset(!.Info, !:Varset),
-        svvarset.new_var(Var, !Varset),
+        varset.new_var(Var, !Varset),
          set_varset(!.Varset, !Info)
      ),
      get_slack_vars(!.Info, Vars),
@@ -848,7 +847,7 @@
  new_art_var(Var, !Info) :-
      some [!Varset] (
          get_varset(!.Info, !:Varset),
-        svvarset.new_var(Var, !Varset),
+        varset.new_var(Var, !Varset),
          set_varset(!.Varset, !Info)
      ),
      get_art_vars(!.Info, Vars),
Index: compiler/lp_rational.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/lp_rational.m,v
retrieving revision 1.15
diff -u -r1.15 lp_rational.m
--- compiler/lp_rational.m	3 May 2011 04:34:55 -0000	1.15
+++ compiler/lp_rational.m	4 May 2011 11:35:02 -0000
@@ -1367,7 +1367,7 @@
  :- pred new_slack_var(lp_var::out, lpr_info::in, lpr_info::out) is det.

  new_slack_var(Var, !LPRInfo) :-
-    varset.new_var(!.LPRInfo ^ lpr_varset, Var, Varset),
+    varset.new_var(Var, !.LPRInfo ^ lpr_varset, Varset),
      !LPRInfo ^ lpr_varset := Varset,
      Vars = !.LPRInfo ^ lpr_slack_vars,
      !LPRInfo ^ lpr_slack_vars := [Var | Vars].
@@ -1375,7 +1375,7 @@
  :- pred new_art_var(lp_var::out, lpr_info::in, lpr_info::out) is det.

  new_art_var(Var, !LPRInfo) :-
-    varset.new_var(!.LPRInfo ^ lpr_varset, Var, Varset),
+    varset.new_var(Var, !.LPRInfo ^ lpr_varset, Varset),
      !LPRInfo ^ lpr_varset := Varset,
      Vars = !.LPRInfo ^ lpr_art_vars,
      !LPRInfo ^ lpr_art_vars := [Var | Vars].
Index: compiler/make_hlds_passes.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make_hlds_passes.m,v
retrieving revision 1.108
diff -u -r1.108 make_hlds_passes.m
--- compiler/make_hlds_passes.m	3 May 2011 04:34:55 -0000	1.108
+++ compiler/make_hlds_passes.m	4 May 2011 11:30:31 -0000
@@ -1966,7 +1966,7 @@
  add_ccsj_constant_mutable_access_preds(TargetMutableName,
          ModuleName, MutableName, Attrs, Inst, BoxPolicy, Context,
          !Status, !ModuleInfo, !QualInfo, !Specs) :-
-    varset.new_named_var(varset.init, "X", X, ProgVarSet),
+    varset.new_named_var("X", X, varset.init, ProgVarSet),
      InstVarSet = varset.init,
      set_purity(purity_pure, Attrs, ConstantGetAttrs0),
      set_thread_safe(proc_thread_safe, ConstantGetAttrs0, ConstantGetAttrs),
@@ -2078,7 +2078,7 @@

      set_purity(purity_semipure, Attrs, UnsafeGetAttrs0),
      set_thread_safe(proc_thread_safe, UnsafeGetAttrs0, UnsafeGetAttrs),
-    varset.new_named_var(varset.init, "X", X, ProgVarSet),
+    varset.new_named_var("X", X, varset.init, ProgVarSet),
      (
          IsThreadLocal = mutable_not_thread_local,
          UnsafeGetCode = "X = " ++ TargetMutableName ++ ";\n"
@@ -2169,7 +2169,7 @@

  add_ccsj_mutable_user_access_preds(ModuleName, MutableName, MutAttrs,
          Lang, Context, !Status, !ModuleInfo, !QualInfo, !Specs) :-
-    varset.new_named_var(varset.init, "X", X, ProgVarSet0),
+    varset.new_named_var("X", X, varset.init, ProgVarSet0),

      LockPredName   = mutable_lock_pred_sym_name(ModuleName, MutableName),
      UnlockPredName = mutable_unlock_pred_sym_name(ModuleName, MutableName),
@@ -2221,7 +2221,7 @@
      IOStateInterface = mutable_var_attach_to_io_state(MutAttrs),
      (
          IOStateInterface = yes,
-        varset.new_named_var(ProgVarSet0, "IO", IO, ProgVarSet),
+        varset.new_named_var("IO", IO, ProgVarSet0, ProgVarSet),

          % Construct the pure get predicate.
          IOGetBody = promise_purity_expr(purity_pure, GetBody) - Context,
@@ -2516,7 +2516,7 @@

      set_purity(purity_semipure, Attrs, GetAttrs0),
      set_thread_safe(proc_thread_safe, GetAttrs0, GetAttrs),
-    varset.new_named_var(varset.init, "X", X, ProgVarSet),
+    varset.new_named_var("X", X, varset.init, ProgVarSet),
      (
          IsThreadLocal = mutable_not_thread_local,
          GetCode = "\tX = " ++ TargetMutableName ++ ";\n"
@@ -2675,7 +2675,7 @@
  add_erlang_constant_mutable_access_preds(TargetMutableName,
          ModuleName, MutableName, Inst,
          Context, !Status, !ModuleInfo, !QualInfo, !Specs) :-
-    varset.new_named_var(varset.init, "X", X, ProgVarSet),
+    varset.new_named_var("X", X, varset.init, ProgVarSet),
      InstVarSet = varset.init,
      Attrs = default_attributes(lang_erlang),
      set_purity(purity_pure, Attrs, ConstantGetAttrs0),
@@ -2727,7 +2727,7 @@
          !Status, !ModuleInfo, !QualInfo, !Specs) :-
      IsThreadLocal = mutable_var_thread_local(MutAttrs),
      Attrs = default_attributes(lang_erlang),
-    varset.new_named_var(varset.init, "X", X, ProgVarSet0),
+    varset.new_named_var("X", X, varset.init, ProgVarSet0),

      % Construct the semipure get predicate.
      set_purity(purity_semipure, Attrs, GetAttrs0),
@@ -2787,7 +2787,7 @@
      IOStateInterface = mutable_var_attach_to_io_state(MutAttrs),
      (
          IOStateInterface = yes,
-        varset.new_named_var(ProgVarSet0, "IO", IO, ProgVarSet),
+        varset.new_named_var("IO", IO, ProgVarSet0, ProgVarSet),
          Ctxt = context_init,

          % Construct the pure get predicate.
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.155
diff -u -r1.155 ml_code_util.m
--- compiler/ml_code_util.m	2 Jan 2011 14:37:55 -0000	1.155
+++ compiler/ml_code_util.m	4 May 2011 11:37:48 -0000
@@ -816,7 +816,7 @@

  ml_make_boxed_types(Arity) = BoxedTypes :-
      varset.init(TypeVarSet0),
-    varset.new_vars(TypeVarSet0, Arity, BoxedTypeVars, _TypeVarSet),
+    varset.new_vars(Arity, BoxedTypeVars, TypeVarSet0, _TypeVarSet),
      prog_type.var_list_to_type_list(map.init, BoxedTypeVars, BoxedTypes).

  ml_java_mercury_type_interface = TypeInterfaceDefn :-
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.154
diff -u -r1.154 ml_unify_gen.m
--- compiler/ml_unify_gen.m	3 May 2011 04:34:56 -0000	1.154
+++ compiler/ml_unify_gen.m	4 May 2011 11:38:28 -0000
@@ -1030,7 +1030,7 @@
          % other type variables (whether constructed the same way or not),
          % nor do I see any reason why such confusion would not lead to errors.
          varset.init(TypeVarSet0),
-        varset.new_var(TypeVarSet0, TypeVar, _TypeVarSet),
+        varset.new_var(TypeVar, TypeVarSet0, _TypeVarSet),
          % The kind is `star' since there are values with this type.
          BoxedFieldType = type_variable(TypeVar, kind_star)
      ;
Index: compiler/mode_constraint_robdd.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/mode_constraint_robdd.m,v
retrieving revision 1.19
diff -u -r1.19 mode_constraint_robdd.m
--- compiler/mode_constraint_robdd.m	3 May 2011 04:34:56 -0000	1.19
+++ compiler/mode_constraint_robdd.m	4 May 2011 07:32:54 -0000
@@ -199,7 +199,7 @@

  init_mode_constraint_info(Simple) = MCI :-
      VarSet0 = varset.init,
-    varset.new_var(VarSet0, ZeroVar, VarSet),
+    varset.new_var(ZeroVar, VarSet0, VarSet),
      PredId = hlds_pred.initial_pred_id,
      MCI = mode_constraint_info(VarSet, bimap.init, PredId, stack.init,
          map.init, map.init, sparse_bitset.init, ZeroVar, Simple, map.init).
@@ -237,7 +237,7 @@
          ( bimap.search(!.MCI ^ mci_varmap, Key, RobddVar0) ->
              RobddVar = RobddVar0
          ;
-            varset.new_var(!.MCI ^ mci_varset, RobddVar, NewVarSet),
+            varset.new_var(RobddVar, !.MCI ^ mci_varset, NewVarSet),
              bimap.set(Key, RobddVar, !.MCI ^ mci_varmap, NewVarMap),
              !MCI ^ mci_varset := NewVarSet,
              !MCI ^ mci_varmap := NewVarMap
Index: compiler/modecheck_goal.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_goal.m,v
retrieving revision 1.5
diff -u -r1.5 modecheck_goal.m
--- compiler/modecheck_goal.m	3 May 2011 04:34:56 -0000	1.5
+++ compiler/modecheck_goal.m	4 May 2011 07:33:43 -0000
@@ -892,7 +892,7 @@
          !ModeInfo) :-
      mode_info_get_var_types(!.ModeInfo, VarTypes0),
      mode_info_get_varset(!.ModeInfo, VarSet0),
-    varset.new_var(VarSet0, CloneVar, VarSet),
+    varset.new_var(CloneVar, VarSet0, VarSet),
      map.lookup(VarTypes0, TermVar, TermVarType),
      map.det_insert(CloneVar, TermVarType, VarTypes0, VarTypes),
      mode_info_set_varset(VarSet, !ModeInfo),
Index: compiler/modecheck_unify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_unify.m,v
retrieving revision 1.138
diff -u -r1.138 modecheck_unify.m
--- compiler/modecheck_unify.m	3 May 2011 04:34:56 -0000	1.138
+++ compiler/modecheck_unify.m	4 May 2011 07:34:20 -0000
@@ -934,7 +934,7 @@
      % introduce a new variable `Var'
      mode_info_get_varset(!.ModeInfo, VarSet0),
      mode_info_get_var_types(!.ModeInfo, VarTypes0),
-    varset.new_var(VarSet0, Var, VarSet),
+    varset.new_var(Var, VarSet0, VarSet),
      map.lookup(VarTypes0, Var0, VarType),
      map.set(Var, VarType, VarTypes0, VarTypes),
      mode_info_set_varset(VarSet, !ModeInfo),
Index: compiler/modecheck_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modecheck_util.m,v
retrieving revision 1.4
diff -u -r1.4 modecheck_util.m
--- compiler/modecheck_util.m	3 May 2011 04:34:56 -0000	1.4
+++ compiler/modecheck_util.m	4 May 2011 07:34:44 -0000
@@ -798,7 +798,7 @@

          % Introduce a new variable.
          mode_info_get_varset(!.ModeInfo, VarSet0),
-        varset.new_var(VarSet0, Var, VarSet),
+        varset.new_var(Var, VarSet0, VarSet),
          map.set(Var, VarType, VarTypes0, VarTypes),
          mode_info_set_varset(VarSet, !ModeInfo),
          mode_info_set_var_types(VarTypes, !ModeInfo),
Index: compiler/polyhedron.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polyhedron.m,v
retrieving revision 1.9
diff -u -r1.9 polyhedron.m
--- compiler/polyhedron.m	3 May 2011 04:34:57 -0000	1.9
+++ compiler/polyhedron.m	4 May 2011 12:01:27 -0000
@@ -188,7 +188,6 @@

  :- import_module pair.
  :- import_module require.
-:- import_module svvarset.
  :- import_module varset.

  %-----------------------------------------------------------------------------%
@@ -410,7 +409,7 @@
  transform_polyhedron(Poly, Polys0, Polys, !PolyInfo) :-
      some [!Varset] (
          !.PolyInfo = polyhedra_info(VarMaps, Sigmas, !:Varset),
-        svvarset.new_var(Sigma, !Varset),
+        varset.new_var(Sigma, !Varset),
          list.map_foldl2(transform_constraint(Sigma), Poly, NewEqns,
              map.init, VarMap, !Varset),
          Polys = NewEqns ++ Polys0,
@@ -449,7 +448,7 @@
          ( map.search(!.VarMap, !.Var, !:Var) ->
              true
          ;
-            svvarset.new_var(NewVar, !Varset),
+            varset.new_var(NewVar, !Varset),
              map.det_insert(!.Var, NewVar, !VarMap),
              !:Var = NewVar
          ),
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.358
diff -u -r1.358 polymorphism.m
--- compiler/polymorphism.m	3 May 2011 04:34:57 -0000	1.358
+++ compiler/polymorphism.m	4 May 2011 12:01:33 -0000
@@ -421,7 +421,6 @@
  :- import_module string.
  :- import_module term.
  :- import_module varset.
-:- import_module svvarset.

  %-----------------------------------------------------------------------------%
  %
@@ -1699,7 +1698,7 @@

  create_fresh_vars([], [], !VarSet, !VarTypes).
  create_fresh_vars([Type | Types], [Var | Vars], !VarSet, !VarTypes) :-
-    varset.new_var(!.VarSet, Var, !:VarSet),
+    varset.new_var(Var, !VarSet),
      map.det_insert(Var, Type, !VarTypes),
      create_fresh_vars(Types, Vars, !VarSet, !VarTypes).

@@ -3170,7 +3169,7 @@
      ( varset.search_name(TypeVarSet, TypeVar, TypeVarName) ->
          poly_info_get_varset(!.Info, VarSet0),
          VarName = "TypeInfo_for_" ++ TypeVarName,
-        varset.name_var(VarSet0, Var, VarName, VarSet),
+        varset.name_var(Var, VarName, VarSet0, VarSet),
          poly_info_set_varset(VarSet, !Info)
      ;
          true
@@ -3192,7 +3191,7 @@

  new_type_info_var_raw(Type, Kind, Var, !VarSet, !VarTypes, !RttiVarMaps) :-
      % Introduce new variable.
-    varset.new_var(!.VarSet, Var, !:VarSet),
+    varset.new_var(Var, !VarSet),
      term.var_to_int(Var, VarNum),
      string.int_to_string(VarNum, VarNumStr),
      (
@@ -3207,7 +3206,7 @@
          % type_ctor_infos in the rtti_varmaps somewhere.
      ),
      Name = Prefix ++ VarNumStr,
-    svvarset.name_var(Var, Name, !VarSet),
+    varset.name_var(Var, Name, !VarSet),
      map.det_insert(Var, type_info_type, !VarTypes).

  %---------------------------------------------------------------------------%
@@ -3385,7 +3384,7 @@
      ClassNameString = unqualify_name(ClassName),

      % Introduce new variable.
-    varset.new_var(VarSet0, Var, VarSet1),
+    varset.new_var(Var, VarSet0, VarSet1),
      (
          VarKind = base_typeclass_info_kind,
          Name = "BaseTypeClassInfo_for_" ++ ClassNameString
@@ -3393,7 +3392,7 @@
          VarKind = typeclass_info_kind,
          Name = "TypeClassInfo_for_" ++ ClassNameString
      ),
-    varset.name_var(VarSet1, Var, Name, VarSet),
+    varset.name_var(Var, Name, VarSet1, VarSet),
      build_typeclass_info_type(Constraint, DictionaryType),
      map.set(Var, DictionaryType, VarTypes0, VarTypes),
      rtti_det_insert_typeclass_info_var(Constraint, Var,
Index: compiler/post_typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/post_typecheck.m,v
retrieving revision 1.146
diff -u -r1.146 post_typecheck.m
--- compiler/post_typecheck.m	3 May 2011 04:34:57 -0000	1.146
+++ compiler/post_typecheck.m	4 May 2011 12:01:40 -0000
@@ -155,7 +155,6 @@
  :- import_module solutions.
  :- import_module string.
  :- import_module set_tree234.
-:- import_module svvarset.
  :- import_module term_io.
  :- import_module varset.

@@ -1415,7 +1414,7 @@
          % Rename apart the existentially quantified type variables.
          list.length(ConsExistQVars, NumExistQVars),
          pred_info_get_typevarset(!.PredInfo, TVarSet0),
-        varset.new_vars(TVarSet0, NumExistQVars, ParentExistQVars, TVarSet),
+        varset.new_vars(NumExistQVars, ParentExistQVars, TVarSet0, TVarSet),
          pred_info_set_typevarset(TVarSet, !PredInfo),
          map.from_corresponding_lists(ConsExistQVars, ParentExistQVars,
              ConsToParentRenaming),
@@ -1594,14 +1593,14 @@

  make_new_vars(Types, Vars, !VarTypes, !VarSet) :-
      list.length(Types, NumVars),
-    svvarset.new_vars(NumVars, Vars, !VarSet),
+    varset.new_vars(NumVars, Vars, !VarSet),
      map.det_insert_from_corresponding_lists(Vars, Types, !VarTypes).

  :- pred make_new_var(mer_type::in, prog_var::out, vartypes::in, vartypes::out,
      prog_varset::in, prog_varset::out) is det.

  make_new_var(Type, Var, !VarTypes, !VarSet) :-
-    svvarset.new_var(Var, !VarSet),
+    varset.new_var(Var, !VarSet),
      map.det_insert(Var, Type, !VarTypes).

  %-----------------------------------------------------------------------------%
Index: compiler/prog_ctgc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_ctgc.m,v
retrieving revision 1.26
diff -u -r1.26 prog_ctgc.m
--- compiler/prog_ctgc.m	15 Dec 2010 06:29:56 -0000	1.26
+++ compiler/prog_ctgc.m	4 May 2011 11:40:17 -0000
@@ -423,7 +423,7 @@

  %-----------------------------------------------------------------------------%

-parse_user_annotated_sharing(Varset, Term, UserSharing) :- 
+parse_user_annotated_sharing(!.Varset, Term, UserSharing) :-
      (
          Term = term.functor(term.atom("no_sharing"), [], _),
          UserSharing = user_sharing(structure_sharing_bottom, no)
@@ -441,9 +441,9 @@
              TypesTerm = term.functor(term.atom("yes"), ListTypeTerms, _),
              maybe_parse_types(ListTypeTerms, Types),
              term.vars_list(ListTypeTerms, TypeVars),
-            varset.select(Varset, set.list_to_set(TypeVars), Varset0),
+            varset.select(set.list_to_set(TypeVars), !Varset),
              MaybeUserTypes = yes(user_type_info(Types, 
-                varset.coerce(Varset0)))
+                varset.coerce(!.Varset)))
          ;
              TypesTerm = term.functor(term.atom("no"), _, _),
              MaybeUserTypes = no
Index: compiler/prog_io_dcg.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_io_dcg.m,v
retrieving revision 1.49
diff -u -r1.49 prog_io_dcg.m
--- compiler/prog_io_dcg.m	8 Sep 2009 02:43:36 -0000	1.49
+++ compiler/prog_io_dcg.m	4 May 2011 11:40:45 -0000
@@ -101,8 +101,8 @@
      counter.allocate(N, !Counter),
      string.int_to_string(N, StringN),
      string.append("DCG_", StringN, VarName),
-    varset.new_var(!.VarSet, DCG_0_Var, !:VarSet),
-    varset.name_var(!.VarSet, DCG_0_Var, VarName, !:VarSet).
+    varset.new_var(DCG_0_Var, !VarSet),
+    varset.name_var(DCG_0_Var, VarName, !VarSet).

  %-----------------------------------------------------------------------------%

Index: compiler/prog_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_util.m,v
retrieving revision 1.113
diff -u -r1.113 prog_util.m
--- compiler/prog_util.m	3 May 2011 04:34:57 -0000	1.113
+++ compiler/prog_util.m	4 May 2011 11:41:50 -0000
@@ -661,10 +661,10 @@
          Vars = []
      ;
          N1 = N + 1,
-        varset.new_var(!.VarSet, Var, !:VarSet),
+        varset.new_var(Var, !VarSet),
          string.int_to_string(N1, Num),
          string.append(BaseName, Num, VarName),
-        varset.name_var(!.VarSet, Var, VarName, !:VarSet),
+        varset.name_var(Var, VarName, !VarSet),
          Vars = [Var | Vars1],
          make_n_fresh_vars_2(BaseName, N1, Max, Vars1, !VarSet)
      ).
@@ -713,13 +713,13 @@
              ( map.search(!.TVarNameMap, TVarName, TVarSetVar) ->
                  map.det_insert(TVar, TVarSetVar, !TVarRenaming)
              ;
-                varset.new_var(!.TVarSet, NewTVar, !:TVarSet),
-                varset.name_var(!.TVarSet, NewTVar, TVarName, !:TVarSet),
+                varset.new_var(NewTVar, !TVarSet),
+                varset.name_var(NewTVar, TVarName, !TVarSet),
                  map.det_insert(TVarName, NewTVar, !TVarNameMap),
                  map.det_insert(TVar, NewTVar, !TVarRenaming)
              )
          ;
-            varset.new_var(!.TVarSet, NewTVar, !:TVarSet),
+            varset.new_var(NewTVar, !TVarSet),
              map.det_insert(TVar, NewTVar, !TVarRenaming)
          )
      ),
Index: compiler/prop_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prop_mode_constraints.m,v
retrieving revision 1.31
diff -u -r1.31 prop_mode_constraints.m
--- compiler/prop_mode_constraints.m	3 May 2011 04:34:57 -0000	1.31
+++ compiler/prop_mode_constraints.m	4 May 2011 12:01:45 -0000
@@ -94,7 +94,6 @@
  :- import_module set.
  :- import_module string.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -438,7 +437,7 @@
          OldVarName = varset.lookup_name(!.Varset, Var0),
          OldVarType = map.lookup(!.VarTypes, Var0),
          NewVarName = "Arg_" ++ OldVarName,
-        svvarset.new_uniquely_named_var(NewVarName, Var, !Varset),
+        varset.new_uniquely_named_var(NewVarName, Var, !Varset),
          map.set(Var, OldVarType, !VarTypes),

          % Make new unification.
Index: compiler/rbmm.region_transformation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/rbmm.region_transformation.m,v
retrieving revision 1.17
diff -u -r1.17 rbmm.region_transformation.m
--- compiler/rbmm.region_transformation.m	3 May 2011 04:34:58 -0000	1.17
+++ compiler/rbmm.region_transformation.m	4 May 2011 12:01:51 -0000
@@ -93,7 +93,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -773,7 +772,7 @@
      ( map.search(!.NameToVar, Name, RegVar0) ->
          RegVar = RegVar0
      ;
-        svvarset.new_named_var(Name, RegVar, !VarSet),
+        varset.new_named_var(Name, RegVar, !VarSet),
          map.det_insert(RegVar, region_type, !VarTypes),
          map.det_insert(Name, RegVar, !NameToVar)
      ).
Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.89
diff -u -r1.89 saved_vars.m
--- compiler/saved_vars.m	3 May 2011 04:34:58 -0000	1.89
+++ compiler/saved_vars.m	4 May 2011 11:35:35 -0000
@@ -596,7 +596,7 @@

  rename_var(Var, NewVar, Substitution, !SlotInfo) :-
      !.SlotInfo = slot_info(Varset0, VarTypes0, RttiVarMaps0, TypeInfoLiveness),
-    varset.new_var(Varset0, NewVar, Varset),
+    varset.new_var(NewVar, Varset0, Varset),
      map.from_assoc_list([Var - NewVar], Substitution),
      map.lookup(VarTypes0, Var, Type),
      map.det_insert(NewVar, Type, VarTypes0, VarTypes),
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.259
diff -u -r1.259 simplify.m
--- compiler/simplify.m	3 May 2011 04:34:58 -0000	1.259
+++ compiler/simplify.m	4 May 2011 07:41:17 -0000
@@ -162,7 +162,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -436,7 +435,7 @@
      simplify_info_get_varset(Info, VarSet0),
      ( simplify_do_after_front_end(Info) ->
          proc_info_get_var_name_remap(!.ProcInfo, VarNameRemap),
-        map.foldl(svvarset.name_var, VarNameRemap, VarSet0, VarSet),
+        map.foldl(varset.name_var, VarNameRemap, VarSet0, VarSet),
          proc_info_set_var_name_remap(map.init, !ProcInfo)
      ;
          VarSet = VarSet0
@@ -2301,7 +2300,7 @@
          !Info) :-
      % Construct the variable to hold the comparison result.
      VarSet0 = !.Info ^ simp_varset,
-    varset.new_var(VarSet0, R, VarSet),
+    varset.new_var(R, VarSet0, VarSet),
      !Info ^ simp_varset := VarSet,

      % We have to add the type of R to the var_types.
@@ -2676,7 +2675,7 @@
  simplify_library_call_int_arity2(Op, X, Y, GoalExpr, !GoalInfo, !Info) :-
      simplify_info_get_varset(!.Info, VarSet0),
      simplify_info_get_var_types(!.Info, VarTypes0),
-    varset.new_var(VarSet0, ConstVar, VarSet),
+    varset.new_var(ConstVar, VarSet0, VarSet),
      map.det_insert(ConstVar, int_type, VarTypes0, VarTypes),
      simplify_info_set_varset(VarSet, !Info),
      simplify_info_set_var_types(VarTypes, !Info),
@@ -3304,7 +3303,7 @@
              list.reverse(RevGoals, Goals1),
              rename_vars_in_goals(need_not_rename, Subn, Goals1, Goals),
              map.keys(Subn0, RemovedVars),
-            varset.delete_vars(VarSet0, RemovedVars, VarSet),
+            varset.delete_vars(RemovedVars, VarSet0, VarSet),
              simplify_info_set_varset(VarSet, !Info),
              simplify_info_get_rtti_varmaps(!.Info, RttiVarMaps0),
              apply_substitutions_to_rtti_varmaps(map.init, map.init, Subn,
@@ -3492,7 +3491,7 @@
          hlds_goal(ExtraGoal, ExtraGoalInfo), !Info) :-
      simplify_info_get_varset(!.Info, VarSet0),
      simplify_info_get_var_types(!.Info, VarTypes0),
-    varset.new_vars(VarSet0, ConsArity, ArgVars, VarSet),
+    varset.new_vars(ConsArity, ArgVars, VarSet0, VarSet),
      map.lookup(VarTypes0, Var, VarType),
      simplify_info_get_module_info(!.Info, ModuleInfo),
      type_util.get_cons_id_arg_types(ModuleInfo, VarType, ConsId, ArgTypes),
Index: compiler/size_prof.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/size_prof.m,v
retrieving revision 1.68
diff -u -r1.68 size_prof.m
--- compiler/size_prof.m	3 May 2011 04:34:58 -0000	1.68
+++ compiler/size_prof.m	4 May 2011 11:45:51 -0000
@@ -1055,11 +1055,11 @@
  get_new_var(Type, Prefix, Var, !Info) :-
      VarSet0 = !.Info ^ spi_varset,
      VarTypes0 = !.Info ^ spi_vartypes,
-    varset.new_var(VarSet0, Var, VarSet1),
+    varset.new_var(Var, VarSet0, VarSet1),
      term.var_to_int(Var, VarNum),
      string.int_to_string(VarNum, VarNumStr),
      string.append(Prefix, VarNumStr, Name),
-    varset.name_var(VarSet1, Var, Name, VarSet),
+    varset.name_var(Var, Name, VarSet1,  VarSet),
      map.set(Var, Type, VarTypes0, VarTypes),
      !Info ^ spi_varset := VarSet,
      !Info ^ spi_vartypes := VarTypes.
Index: compiler/ssdebug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/ssdebug.m,v
retrieving revision 1.35
diff -u -r1.35 ssdebug.m
--- compiler/ssdebug.m	3 May 2011 04:34:58 -0000	1.35
+++ compiler/ssdebug.m	4 May 2011 12:01:59 -0000
@@ -214,7 +214,6 @@
  :- import_module maybe.
  :- import_module require.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -981,7 +980,7 @@
      SSDBModule = mercury_ssdb_builtin_module,
      TypeCtor = type_ctor(qualified(SSDBModule, "ssdb_retry"), 0),
      construct_type(TypeCtor, [], RetryType),
-    svvarset.new_named_var(VarName, RetryVar, !VarSet),
+    varset.new_named_var(VarName, RetryVar, !VarSet),
      map.det_insert(RetryVar, RetryType, !VarTypes).

      % Create the goal for recursive call in the case of a retry.
@@ -1148,7 +1147,7 @@
      SSDBModule = mercury_ssdb_builtin_module,
      TypeCtor = type_ctor(qualified(SSDBModule, "ssdb_proc_id"), 0),

-    svvarset.new_named_var("ProcId", ProcIdVar, !VarSet),
+    varset.new_named_var("ProcId", ProcIdVar, !VarSet),
      ConsId = cons(qualified(SSDBModule, "ssdb_proc_id"), 2, TypeCtor),
      construct_type(TypeCtor, [], ProcIdType),
      map.det_insert(ProcIdVar, ProcIdType, !VarTypes),
@@ -1204,7 +1203,7 @@

  make_arg_list(_Pos, _InstMap, [], _Renaming, OutVar, [Goal], !ModuleInfo,
          !ProcInfo, !PredInfo, !VarSet, !VarTypes, !BoundVarDescs) :-
-    svvarset.new_named_var("EmptyVarList", OutVar, !VarSet),
+    varset.new_named_var("EmptyVarList", OutVar, !VarSet),
      map.det_insert(OutVar, list_var_value_type, !VarTypes),
      ListTypeSymName = qualified(mercury_list_module, "list"),
      ListTypeCtor = type_ctor(ListTypeSymName, 1),
@@ -1241,7 +1240,7 @@
                  !VarTypes, !BoundVarDescs)
          ),

-        svvarset.new_named_var("FullListVar", OutVar, !VarSet),
+        varset.new_named_var("FullListVar", OutVar, !VarSet),
          map.det_insert(OutVar, list_var_value_type, !VarTypes),
          ListTypeSymName = qualified(mercury_list_module, "list"),
          ListTypeCtor = type_ctor(ListTypeSymName, 1),
@@ -1286,7 +1285,7 @@
      make_int_const_construction_alloc(VarPos, yes("VarPos"),
          ConstructVarPos, VarPosVar, !VarSet, !VarTypes),

-    svvarset.new_named_var("VarDesc", VarDesc, !VarSet),
+    varset.new_named_var("VarDesc", VarDesc, !VarSet),
      ( var_is_ground_in_instmap(!.ModuleInfo, InstMap, VarToInspect) ->
          % Update proc_varset and proc_vartypes; without this,
          % polymorphism_make_type_info_var uses a prog_var which is
Index: compiler/state_var.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/state_var.m,v
retrieving revision 1.37
diff -u -r1.37 state_var.m
--- compiler/state_var.m	3 May 2011 04:34:58 -0000	1.37
+++ compiler/state_var.m	4 May 2011 11:31:53 -0000
@@ -383,15 +383,15 @@
      (
          NameSource = name_initial,
          ProgVarName = string.format("STATE_VARIABLE_%s_0", [s(SVarName)]),
-        varset.new_named_var(!.VarSet, ProgVarName, Var, !:VarSet)
+        varset.new_named_var(ProgVarName, Var, !VarSet)
      ;
          NameSource = name_middle,
          ProgVarBaseName = string.format("STATE_VARIABLE_%s", [s(SVarName)]),
-        varset.new_uniquely_named_var(!.VarSet, ProgVarBaseName, Var, !:VarSet)
+        varset.new_uniquely_named_var(ProgVarBaseName, Var, !VarSet)
      ;
          NameSource = name_final,
          ProgVarName = string.format("STATE_VARIABLE_%s", [s(SVarName)]),
-        varset.new_named_var(!.VarSet, ProgVarName, Var, !:VarSet)
+        varset.new_named_var(ProgVarName, Var, !VarSet)
      ).

  %-----------------------------------------------------------------------------%
Index: compiler/stm_expand.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/stm_expand.m,v
retrieving revision 1.16
diff -u -r1.16 stm_expand.m
--- compiler/stm_expand.m	3 May 2011 04:34:58 -0000	1.16
+++ compiler/stm_expand.m	4 May 2011 11:50:37 -0000
@@ -200,7 +200,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -1260,7 +1259,7 @@
      map.lookup(!.OldPredVarTypes, ProgVar, ProgType),
  %   delete_var(!.OldPredVarSet, ProgVar, !:OldPredVarSet),
  %   map.delete(!.OldPredVarTypes, ProgVar, !:OldPredVarTypes),
-    new_var(NewProgVar, !NewPredVarSet),
+    varset.new_var(NewProgVar, !NewPredVarSet),
      map.det_insert(NewProgVar, ProgType, !NewPredVarTypes),
      map.det_insert(ProgVar, NewProgVar, !VarMapping).

@@ -2066,10 +2065,10 @@
      proc_info_get_varset(NewProcInfo0, NewPredVarSet0),
      proc_info_get_vartypes(NewProcInfo0, NewPredVarTypes0),
      proc_info_get_headvars(NewProcInfo0, NewHeadVars0),
-    delete_var(NewPredVarSet0, ResultVar0, NewPredVarSet1),
+    varset.delete_var(ResultVar0, NewPredVarSet0, NewPredVarSet1),
      map.delete(ResultVar0, NewPredVarTypes0, NewPredVarTypes1),

-    new_named_var(Name, ResultVar, NewPredVarSet1, NewPredVarSet),
+    varset.new_named_var(Name, ResultVar, NewPredVarSet1, NewPredVarSet),
      map.det_insert(ResultVar, ResultType, NewPredVarTypes1, NewPredVarTypes),

      VarMapping0 = map.init,
@@ -2485,7 +2484,7 @@
  set_head_vars(NewHeadVars, !NewPredInfo) :-
      ProcInfo0 = !.NewPredInfo ^ new_pred_proc_info,
      proc_info_set_headvars(NewHeadVars, ProcInfo0, ProcInfo),
-    !:NewPredInfo = !.NewPredInfo ^ new_pred_proc_info := ProcInfo.
+    !NewPredInfo ^ new_pred_proc_info := ProcInfo.

      % Writes the changes made to the new predicate to the predicate table
      % and returns an updates the stm_info state.
@@ -2512,7 +2511,7 @@

  update_new_pred_info(StmInfo, !NewPredInfo) :-
      ModuleInfo = StmInfo ^ stm_info_module_info,
-    !:NewPredInfo = !.NewPredInfo ^ new_pred_module_info := ModuleInfo.
+    !NewPredInfo ^ new_pred_module_info := ModuleInfo.

      % Runs quantification and recalculates the instmap-delta over the
      % new predicate.
@@ -2527,8 +2526,8 @@
          ProcInfo0, ProcInfo1),
      recompute_instmap_delta_proc(recompute_atomic_instmap_deltas,
          ProcInfo1, ProcInfo, ModuleInfo0, ModuleInfo),
-    !:NewPredInfo = !.NewPredInfo ^ new_pred_module_info := ModuleInfo,
-    !:NewPredInfo = !.NewPredInfo ^ new_pred_proc_info := ProcInfo.
+    !NewPredInfo ^ new_pred_module_info := ModuleInfo,
+    !NewPredInfo ^ new_pred_proc_info := ProcInfo.

      % Sets the goal of the new predicate.
      %
@@ -2541,13 +2540,13 @@
      proc_info_get_varset(ProcInfo0, ProcVarSet0),
      proc_info_get_vartypes(ProcInfo0, ProcVarTypes0),

-    varset.select(ProcVarSet0, GoalVars0, ProgVarSet),
+    varset.select(GoalVars0, ProcVarSet0, ProgVarSet),
      map.select(ProcVarTypes0, GoalVars0, ProcVarTypes),

      proc_info_set_varset(ProgVarSet, ProcInfo0, ProcInfo1),
      proc_info_set_goal(HldsGoal, ProcInfo1, ProcInfo2),
      proc_info_set_vartypes(ProcVarTypes, ProcInfo2, ProcInfo),
-    !:NewPredInfo = !.NewPredInfo ^ new_pred_proc_info := ProcInfo.
+    !NewPredInfo ^ new_pred_proc_info := ProcInfo.

      % Returns the pred_proc_id of the new predicate.
      %
Index: compiler/superhomogeneous.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/superhomogeneous.m,v
retrieving revision 1.42
diff -u -r1.42 superhomogeneous.m
--- compiler/superhomogeneous.m	7 Mar 2011 03:59:29 -0000	1.42
+++ compiler/superhomogeneous.m	4 May 2011 11:32:52 -0000
@@ -141,7 +141,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -494,7 +493,7 @@
          % away type errors.
          TermX = term.functor(_, _, _),
          TermY = term.functor(_, _, _),
-        varset.new_var(!.VarSet, TmpVar, !:VarSet),
+        varset.new_var(TmpVar, !VarSet),
          do_unravel_unification(term.variable(TmpVar, Context), TermX,
              Context, MainContext, SubContext, Purity, GoalX, no, NumAddedX,
              !SVarState, !SVarStore, !VarSet, !ModuleInfo, !QualInfo, !Specs),
@@ -976,7 +975,7 @@
              % becoming lambda-quantified.

              list.length(Args, NumArgs),
-            svvarset.new_vars(NumArgs, LambdaVars, !VarSet),
+            varset.new_vars(NumArgs, LambdaVars, !VarSet),

              % Partition the arguments (and their corresponding lambda vars)
              % into two sets: those that are not output, i.e. input and unused,
@@ -1181,7 +1180,7 @@
  make_fresh_arg_vars_loop([Arg | Args], !RevVars, !VarSet, !SVarState,
          !Specs) :-
      make_fresh_arg_var(Arg, Var, !.RevVars, !VarSet, !SVarState, !Specs),
-    !:RevVars  =[Var | !.RevVars], 
+    !:RevVars = [Var | !.RevVars],
      make_fresh_arg_vars_loop(Args, !RevVars, !VarSet, !SVarState, !Specs).

  make_fresh_arg_var(Arg0, Var, Vars0, !VarSet, !SVarState, !Specs) :-
@@ -1192,7 +1191,7 @@
      ->
          Var = ArgVar
      ;
-        varset.new_var(!.VarSet, Var, !:VarSet)
+        varset.new_var(Var, !VarSet)
      ).

  %-----------------------------------------------------------------------------%
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.160
diff -u -r1.160 table_gen.m
--- compiler/table_gen.m	3 May 2011 04:34:59 -0000	1.160
+++ compiler/table_gen.m	4 May 2011 11:52:11 -0000
@@ -3150,7 +3150,7 @@
      prog_var::out) is det.

  generate_new_table_var(Name, Type, !VarSet, !VarTypes, Var) :-
-    varset.new_named_var(!.VarSet, Name, Var, !:VarSet),
+    varset.new_named_var(Name, Var, !VarSet),
      map.set(Var, Type, !VarTypes).

  :- pred table_generate_call(string::in, determinism::in, list(prog_var)::in,
@@ -3736,7 +3736,7 @@

  dummy_type_var = Type :-
      varset.init(DummyTVarSet0),
-    varset.new_var(DummyTVarSet0, DummyTVar, _),
+    varset.new_var(DummyTVar, DummyTVarSet0, _),
      Type = type_variable(DummyTVar, kind_star).

  %-----------------------------------------------------------------------------%
Index: compiler/term_constr_build.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_build.m,v
retrieving revision 1.30
diff -u -r1.30 term_constr_build.m
--- compiler/term_constr_build.m	3 May 2011 04:34:59 -0000	1.30
+++ compiler/term_constr_build.m	4 May 2011 12:02:05 -0000
@@ -85,7 +85,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module std_util.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -1080,7 +1079,7 @@
      ( map.search(!.SizeVarMap, ProgVar, _) ->
          possibly_fix_sizevar_map(ProgVars, !SizeVarset, !SizeVarMap)
      ;
-        svvarset.new_var(SizeVar, !SizeVarset),
+        varset.new_var(SizeVar, !SizeVarset),
          map.set(ProgVar, SizeVar, !SizeVarMap),
          possibly_fix_sizevar_map(ProgVars, !SizeVarset, !SizeVarMap)
      ).
Index: compiler/term_constr_util.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_constr_util.m,v
retrieving revision 1.21
diff -u -r1.21 term_constr_util.m
--- compiler/term_constr_util.m	3 May 2011 04:34:59 -0000	1.21
+++ compiler/term_constr_util.m	4 May 2011 12:02:11 -0000
@@ -202,7 +202,6 @@
  :- import_module set.
  :- import_module std_util.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -243,7 +242,7 @@
      size_varset::in, size_varset::out) is det.

  make_size_var_map_2(ProgVar, !SizeVarMap, !SizeVarset) :-
-    svvarset.new_var(SizeVar, !SizeVarset),
+    varset.new_var(SizeVar, !SizeVarset),
      map.set(ProgVar, SizeVar, !SizeVarMap).

  prog_vars_to_size_vars(SizeVarMap, Vars)
Index: compiler/term_pass1.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/term_pass1.m,v
retrieving revision 1.43
diff -u -r1.43 term_pass1.m
--- compiler/term_pass1.m	3 May 2011 04:34:59 -0000	1.43
+++ compiler/term_pass1.m	4 May 2011 12:02:16 -0000
@@ -69,7 +69,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -473,7 +472,7 @@
      ( map.search(!.PPVars, PPId, Var0) ->
          Var = Var0
      ;
-        svvarset.new_var(Var, !Varset),
+        varset.new_var(Var, !Varset),
          map.det_insert(PPId, Var, !PPVars)
      ).

Index: compiler/tupling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/tupling.m,v
retrieving revision 1.57
diff -u -r1.57 tupling.m
--- compiler/tupling.m	3 May 2011 04:34:59 -0000	1.57
+++ compiler/tupling.m	4 May 2011 12:02:25 -0000
@@ -138,7 +138,6 @@
  :- import_module require.
  :- import_module set.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module unit.
  :- import_module varset.
@@ -569,7 +568,7 @@
          % We need a new variable to act as the cell variable while
          % counting loads/stores for a proposed tupling, but we don't
          % add that variable to the varset permanently.
-        varset.new_named_var(VarSet, "DummyCellVar", DummyCellVar, _),
+        varset.new_named_var("DummyCellVar", DummyCellVar, VarSet, _),
          FieldVars = assoc_list.keys(FieldVarArgPos),
          TuplingProposal = tupling(DummyCellVar, FieldVars, FieldVarArgPos)
      ).
@@ -1735,7 +1734,7 @@
              TransformedProc = transformed_proc(_, TupleConsType, ArgsToTuple,
                  hlds_goal(CallAux0, CallAuxInfo))
          ->
-            svvarset.new_named_var("TuplingCellVarForCall", CellVar, !VarSet),
+            varset.new_named_var("TuplingCellVarForCall", CellVar, !VarSet),
              map.det_insert(CellVar, TupleConsType, !VarTypes),
              extract_tupled_args_from_list(Args0, ArgsToTuple,
                  TupledArgs, UntupledArgs),
Index: compiler/type_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/type_constraints.m,v
retrieving revision 1.14
diff -u -r1.14 type_constraints.m
--- compiler/type_constraints.m	3 May 2011 04:34:59 -0000	1.14
+++ compiler/type_constraints.m	4 May 2011 12:02:31 -0000
@@ -63,7 +63,6 @@
  :- import_module set.
  :- import_module string.
  :- import_module svset.
-:- import_module svvarset.
  :- import_module term.
  :- import_module term_io.
  :- import_module varset.
@@ -1822,7 +1821,7 @@
              HOType = higher_order_type(ArgTypes, no, Purity, lambda_normal)
          ;
              Kind = pf_function,
-            svvarset.new_var(FunctionTVar, !.TCInfo ^ tconstr_tvarset,
+            varset.new_var(FunctionTVar, !.TCInfo ^ tconstr_tvarset,
                  NewTVarSet),
              !TCInfo ^ tconstr_tvarset := NewTVarSet,
              HOType = apply_n_type(FunctionTVar, ArgTypes, kind_star)
@@ -2192,7 +2191,7 @@
      ( bimap.search(!.VarMap, Var, TVar0) ->
          TVar = TVar0
      ;
-        svvarset.new_var(TVar, !TVarSet),
+        varset.new_var(TVar, !TVarSet),
          bimap.det_insert(Var, TVar, !VarMap)
      ).

Index: compiler/typecheck.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/typecheck.m,v
retrieving revision 1.455
diff -u -r1.455 typecheck.m
--- compiler/typecheck.m	3 May 2011 04:34:59 -0000	1.455
+++ compiler/typecheck.m	4 May 2011 07:45:04 -0000
@@ -798,7 +798,7 @@
      pred_info_set_markers(Markers, !PredInfo),

      % Generate `PredName = "<PredName>"'.
-    varset.new_named_var(!.VarSet, "PredName", PredNameVar, !:VarSet),
+    varset.new_named_var("PredName", PredNameVar, !VarSet),
      make_string_const_construction(PredNameVar, PredName, UnifyGoal),

      % Generate `private_builtin.no_clauses(PredName)'
@@ -1461,7 +1461,7 @@
          % each must have kind `star'.
          list.length(Vars, NumVars),
          varset.init(TypeVarSet0),
-        varset.new_vars(TypeVarSet0, NumVars, TypeVars, TypeVarSet),
+        varset.new_vars(NumVars, TypeVars, TypeVarSet0, TypeVarSet),
          prog_type.var_list_to_type_list(map.init, TypeVars, Types),
          empty_hlds_constraints(EmptyConstraints),
          typecheck_var_has_polymorphic_type_list(Vars, TypeVarSet, [],
@@ -1482,7 +1482,7 @@
          % variables. Since the type is the type of a program variable,
          % each must have kind `star'.
          varset.init(TypeVarSet0),
-        varset.new_var(TypeVarSet0, TypeVar, TypeVarSet),
+        varset.new_var(TypeVar, TypeVarSet0, TypeVarSet),
          Type = type_variable(TypeVar, kind_star),
          list.length(Vars, NumVars),
          list.duplicate(NumVars, Type, Types),
@@ -1520,7 +1520,7 @@
  higher_order_pred_type(Purity, Arity, EvalMethod, TypeVarSet, PredType,
          ArgTypes) :-
      varset.init(TypeVarSet0),
-    varset.new_vars(TypeVarSet0, Arity, ArgTypeVars, TypeVarSet),
+    varset.new_vars(Arity, ArgTypeVars, TypeVarSet0, TypeVarSet),
      % Argument types always have kind `star'.
      prog_type.var_list_to_type_list(map.init, ArgTypeVars, ArgTypes),
      construct_higher_order_type(Purity, pf_predicate, EvalMethod, ArgTypes,
@@ -1540,8 +1540,8 @@
  higher_order_func_type(Purity, Arity, EvalMethod, TypeVarSet,
          FuncType, ArgTypes, RetType) :-
      varset.init(TypeVarSet0),
-    varset.new_vars(TypeVarSet0, Arity, ArgTypeVars, TypeVarSet1),
-    varset.new_var(TypeVarSet1, RetTypeVar, TypeVarSet),
+    varset.new_vars(Arity, ArgTypeVars, TypeVarSet0, TypeVarSet1),
+    varset.new_var(RetTypeVar, TypeVarSet1, TypeVarSet),
      % Argument and return types always have kind `star'.
      prog_type.var_list_to_type_list(map.init, ArgTypeVars, ArgTypes),
      RetType = type_variable(RetTypeVar, kind_star),
@@ -2283,7 +2283,7 @@
              % Both X and Y are fresh variables - introduce a fresh type
              % variable with kind `star' to represent their type.
              type_assign_get_typevarset(TypeAssign0, TypeVarSet0),
-            varset.new_var(TypeVarSet0, TypeVar, TypeVarSet),
+            varset.new_var(TypeVar, TypeVarSet0, TypeVarSet),
              type_assign_set_typevarset(TypeVarSet, TypeAssign0, TypeAssign1),
              Type = type_variable(TypeVar, kind_star),
              map.det_insert(X, Type, VarTypes0, VarTypes1),
@@ -2488,7 +2488,7 @@
          % Otherwise, introduce a fresh type variable with kind `star' to use
          % as the type of that variable.
          type_assign_get_typevarset(!.TypeAssign, TypeVarSet0),
-        varset.new_var(TypeVarSet0, TypeVar, TypeVarSet),
+        varset.new_var(TypeVar, TypeVarSet0, TypeVarSet),
          type_assign_set_typevarset(TypeVarSet, !TypeAssign),
          Type = type_variable(TypeVar, kind_star),
          map.det_insert(Var, Type, VarTypes0, VarTypes1),
@@ -2896,7 +2896,7 @@
                      TVarsInOtherArgs, TVarsOnlyInField0),
                  list.sort_and_remove_dups(TVarsOnlyInField0, TVarsOnlyInField),
                  list.length(TVarsOnlyInField, NumNewTVars),
-                varset.new_vars(TVarSet0, NumNewTVars, NewTVars, TVarSet),
+                varset.new_vars(NumNewTVars, NewTVars, TVarSet0, TVarSet),
                  map.from_corresponding_lists(TVarsOnlyInField,
                      NewTVars, TVarRenaming),
                  apply_variable_renaming_to_type(TVarRenaming, FieldType,
@@ -3105,8 +3105,8 @@
          % tuple constructor) which have these types.

          varset.init(TupleConsTypeVarSet0),
-        varset.new_vars(TupleConsTypeVarSet0, TupleArity, TupleArgTVars,
-            TupleConsTypeVarSet),
+        varset.new_vars(TupleArity, TupleArgTVars,
+            TupleConsTypeVarSet0, TupleConsTypeVarSet),
          prog_type.var_list_to_type_list(map.init, TupleArgTVars,
              TupleArgTypes),

Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.218
diff -u -r1.218 unify_proc.m
--- compiler/unify_proc.m	3 May 2011 05:12:03 -0000	1.218
+++ compiler/unify_proc.m	4 May 2011 11:07:06 -0000
@@ -383,7 +383,7 @@
          % Build a hlds_type_body for the tuple constructor, which will
          % be used by generate_clause_info.
          varset.init(TVarSet0),
-        varset.new_vars(TVarSet0, TupleArity, TupleArgTVars, TVarSet),
+        varset.new_vars(TupleArity, TupleArgTVars, TVarSet0, TVarSet),
          prog_type.var_list_to_type_list(map.init, TupleArgTVars,
              TupleArgTypes),

@@ -1880,7 +1880,7 @@
          % up to typecheck.m to infer their types.
          info_get_varset(!.Info, VarSet0),
          list.length(CtorArgs, NumVars),
-        varset.new_vars(VarSet0, NumVars, Vars, VarSet),
+        varset.new_vars(NumVars, Vars, VarSet0, VarSet),
          info_set_varset(VarSet, !Info)
      ).

@@ -2076,13 +2076,13 @@
      UPI = unify_proc_info(VarSet, Types, RttiVarMaps, ModuleInfo).

  info_new_var(Type, Var, !UPI) :-
-    varset.new_var(!.UPI ^ upi_varset, Var, VarSet),
+    varset.new_var(Var, !.UPI ^ upi_varset, VarSet),
      map.det_insert(Var, Type, !.UPI ^ upi_vartypes, VarTypes),
      !UPI ^ upi_varset := VarSet,
      !UPI ^ upi_vartypes := VarTypes.

  info_new_named_var(Type, Name, Var, !UPI) :-
-    varset.new_named_var(!.UPI ^ upi_varset, Name, Var, VarSet),
+    varset.new_named_var(Name, Var, !.UPI ^ upi_varset, VarSet),
      map.det_insert(Var, Type, !.UPI ^ upi_vartypes, VarTypes),
      !UPI ^ upi_varset := VarSet,
      !UPI ^ upi_vartypes := VarTypes.
Index: compiler/untupling.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/untupling.m,v
retrieving revision 1.38
diff -u -r1.38 untupling.m
--- compiler/untupling.m	3 May 2011 04:34:59 -0000	1.38
+++ compiler/untupling.m	4 May 2011 12:02:44 -0000
@@ -122,7 +122,6 @@
  :- import_module pair.
  :- import_module require.
  :- import_module string.
-:- import_module svvarset.
  :- import_module term.
  :- import_module varset.

@@ -357,7 +356,7 @@
  create_untuple_vars(ParentName, Num, [Type | Types], [NewVar | NewVars],
          !VarSet, !VarTypes) :-
      string.format("Untupled_%s_%d", [s(ParentName), i(Num)], Name),
-    svvarset.new_named_var(Name, NewVar, !VarSet),
+    varset.new_named_var(Name, NewVar, !VarSet),
      map.det_insert(NewVar, Type, !VarTypes),
      create_untuple_vars(ParentName, Num+1, Types, NewVars, !VarSet, !VarTypes).

@@ -659,7 +658,7 @@
      (
          Expansion = expansion(ConsId, Types),
          NumVars = list.length(Types),
-        svvarset.new_vars(NumVars, ReplacementArgs, !VarSet),
+        varset.new_vars(NumVars, ReplacementArgs, !VarSet),
          map.det_insert_from_corresponding_lists(
              ReplacementArgs, Types, !VarTypes),
          list.duplicate(NumVars, ArgMode, ReplacementModes),
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.166
diff -u -r1.166 unused_args.m
--- compiler/unused_args.m	3 May 2011 04:34:59 -0000	1.166
+++ compiler/unused_args.m	4 May 2011 11:53:35 -0000
@@ -1542,9 +1542,9 @@
          VarSet0 = !.Info ^ fixup_varset,
          VarTypes0 = !.Info ^ fixup_vartypes,
          ( varset.search_name(VarSet0, OldVar, Name) ->
-            varset.new_named_var(VarSet0, Name, NewVar, VarSet)
+            varset.new_named_var(Name, NewVar, VarSet0, VarSet)
          ;
-            varset.new_var(VarSet0, NewVar, VarSet)
+            varset.new_var(NewVar, VarSet0, VarSet)
          ),
          map.lookup(VarTypes0, OldVar, Type),
          map.det_insert(NewVar, Type, VarTypes0, VarTypes),
Index: library/parser.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/parser.m,v
retrieving revision 1.62
diff -u -r1.62 parser.m
--- library/parser.m	3 May 2011 04:35:01 -0000	1.62
+++ library/parser.m	4 May 2011 07:21:08 -0000
@@ -1069,7 +1069,7 @@
  add_var(VarName, Var, ParserState0, ParserState) :-
      ( VarName = "_" ->
          VarSet0 = parser_state_get_varset(ParserState0),
-        varset.new_var(VarSet0, Var, VarSet),
+        varset.new_var(Var, VarSet0, VarSet),
          ParserState = parser_state_set_varset(ParserState0, VarSet)
      ;
          Names0 = parser_state_get_var_names(ParserState0),
@@ -1078,7 +1078,7 @@
              ParserState = ParserState0
          ;
              VarSet0 = parser_state_get_varset(ParserState0),
-            varset.new_named_var(VarSet0, VarName, Var, VarSet),
+            varset.new_named_var(VarName, Var, VarSet0, VarSet),
              map.det_insert(VarName, Var, Names0, Names),
              ParserState1 = parser_state_set_varset(ParserState0, VarSet),
              ParserState = parser_state_set_var_names(ParserState1, Names)
Index: library/svvarset.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/svvarset.m,v
retrieving revision 1.9
diff -u -r1.9 svvarset.m
--- library/svvarset.m	27 Sep 2006 06:16:44 -0000	1.9
+++ library/svvarset.m	4 May 2011 07:23:36 -0000
@@ -89,38 +89,38 @@

  :- implementation.

-svvarset.new_var(Var, Varset0, Varset) :-
-    varset.new_var(Varset0, Var, Varset).
+svvarset.new_var(Var, !Varset) :-
+    varset.new_var(Var, !Varset).

-svvarset.new_named_var(Name, Var, Varset0, Varset) :-
-    varset.new_named_var(Varset0, Name, Var, Varset).
+svvarset.new_named_var(Name, Var, !Varset) :-
+    varset.new_named_var(Name, Var, !Varset).

-svvarset.new_maybe_named_var(MaybeName, Var, Varset0, Varset) :-
-    varset.new_maybe_named_var(Varset0, MaybeName, Var, Varset).
+svvarset.new_maybe_named_var(MaybeName, Var, !Varset) :-
+    varset.new_maybe_named_var(MaybeName, Var, !Varset).

-svvarset.new_uniquely_named_var(Name, Var, Varset0, Varset) :-
-    varset.new_uniquely_named_var(Varset0, Name, Var, Varset).
+svvarset.new_uniquely_named_var(Name, Var, !Varset) :-
+    varset.new_uniquely_named_var(Name, Var, !Varset).

-svvarset.new_vars(NumVars, NewVars, Varset0, Varset) :-
-    varset.new_vars(Varset0, NumVars, NewVars, Varset).
+svvarset.new_vars(NumVars, NewVars, !Varset) :-
+    varset.new_vars(NumVars, NewVars, !Varset).

-svvarset.delete_var(Var, Varset0, Varset) :-
-    varset.delete_var(Varset0, Var, Varset).
+svvarset.delete_var(Var, !Varset) :-
+    varset.delete_var(Var, !Varset).

-svvarset.delete_vars(Vars, Varset0, Varset) :-
-    varset.delete_vars(Varset0, Vars, Varset).
+svvarset.delete_vars(Vars, !Varset) :-
+    varset.delete_vars(Vars, !Varset).

-svvarset.name_var(Id, Name, Varset0, Varset) :-
-    varset.name_var(Varset0, Id, Name, Varset).
+svvarset.name_var(Id, Name, !Varset) :-
+    varset.name_var(Id, Name, !Varset).

-svvarset.bind_var(Id, Val, Varset0, Varset) :-
-    varset.bind_var(Varset0, Id, Val, Varset).
+svvarset.bind_var(Id, Val, !Varset) :-
+    varset.bind_var(Id, Val, !Varset).

-svvarset.bind_vars(Subst, Varset0, Varset) :-
-    varset.bind_vars(Varset0, Subst, Varset).
+svvarset.bind_vars(Subst, !Varset) :-
+    varset.bind_vars(Subst, !Varset).

-svvarset.select(Vars, Varset0, Varset) :-
-    varset.select(Varset0, Vars, Varset).
+svvarset.select(Vars, !Varset) :-
+    varset.select(Vars, !Varset).

  %-----------------------------------------------------------------------------%
  :- end_module svvarset.
Index: library/term_io.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/term_io.m,v
retrieving revision 1.88
diff -u -r1.88 term_io.m
--- library/term_io.m	4 Apr 2011 07:10:40 -0000	1.88
+++ library/term_io.m	4 May 2011 07:20:39 -0000
@@ -321,7 +321,7 @@
          term.var_to_int(Id, VarNum),
          string.int_to_string(VarNum, Num),
          string.append("_", Num, VarName),
-        varset.name_var(!.VarSet, Id, VarName, !:VarSet),
+        varset.name_var(Id, VarName, !VarSet),
          !:N = !.N + 1,
          io.write_string(VarName, !IO)
      ).
Index: library/varset.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/varset.m,v
retrieving revision 1.87
diff -u -r1.87 varset.m
--- library/varset.m	3 May 2011 04:35:01 -0000	1.87
+++ library/varset.m	4 May 2011 07:20:19 -0000
@@ -55,38 +55,38 @@

      % Create a new variable.
      %
-:- pred varset.new_var(varset(T)::in, var(T)::out, varset(T)::out) is det.
+:- pred varset.new_var(var(T)::out, varset(T)::in, varset(T)::out) is det.

      % Create a new named variable.
      %
-:- pred varset.new_named_var(varset(T)::in, string::in, var(T)::out,
-    varset(T)::out) is det.
+:- pred varset.new_named_var(string::in, var(T)::out,
+    varset(T)::in, varset(T)::out) is det.

      % Create a new named variable with a unique (w.r.t. the
      % varset) number appended to the name.
      %
-:- pred varset.new_uniquely_named_var(varset(T)::in, string::in, var(T)::out,
-    varset(T)::out) is det.
+:- pred varset.new_uniquely_named_var(string::in, var(T)::out,
+    varset(T)::in, varset(T)::out) is det.

      % Create a new variable, and maybe give it a name.
      %
-:- pred varset.new_maybe_named_var(varset(T)::in, maybe(string)::in,
-    var(T)::out, varset(T)::out) is det.
+:- pred varset.new_maybe_named_var(maybe(string)::in, var(T)::out,
+    varset(T)::in, varset(T)::out) is det.

      % Create multiple new variables.
      %
-:- pred varset.new_vars(varset(T)::in, int::in, list(var(T))::out,
-    varset(T)::out) is det.
+:- pred varset.new_vars(int::in, list(var(T))::out,
+    varset(T)::in, varset(T)::out) is det.

      % Delete the name and value for a variable.
      %
  :- func varset.delete_var(varset(T), var(T)) = varset(T).
-:- pred varset.delete_var(varset(T)::in, var(T)::in, varset(T)::out) is det.
+:- pred varset.delete_var(var(T)::in, varset(T)::in, varset(T)::out) is det.

      % Delete the names and values for a list of variables.
      %
  :- func varset.delete_vars(varset(T), list(var(T))) = varset(T).
-:- pred varset.delete_vars(varset(T)::in, list(var(T))::in, varset(T)::out)
+:- pred varset.delete_vars(list(var(T))::in, varset(T)::in, varset(T)::out)
      is det.

      % Return a list of all the variables in a varset.
@@ -97,8 +97,8 @@
      % Set the name of a variable.
      %
  :- func varset.name_var(varset(T), var(T), string) = varset(T).
-:- pred varset.name_var(varset(T)::in, var(T)::in, string::in, varset(T)::out)
-    is det.
+:- pred varset.name_var(var(T)::in, string::in,
+    varset(T)::in, varset(T)::out) is det.

      % Lookup the name of a variable;
      % create one if it doesn't have one using V_ as a prefix.
@@ -122,14 +122,14 @@
      % This will overwrite any existing binding.
      %
  :- func varset.bind_var(varset(T), var(T), term(T)) = varset(T).
-:- pred varset.bind_var(varset(T)::in, var(T)::in, term(T)::in,
-    varset(T)::out) is det.
+:- pred varset.bind_var(var(T)::in, term(T)::in,
+    varset(T)::in, varset(T)::out) is det.

      % Bind a set of terms to a set of variables.
      %
  :- func varset.bind_vars(varset(T), substitution(T)) = varset(T).
-:- pred varset.bind_vars(varset(T)::in, substitution(T)::in, varset(T)::out)
-    is det.
+:- pred varset.bind_vars(substitution(T)::in,
+    varset(T)::in, varset(T)::out) is det.

      % Lookup the value of a variable.
      %
@@ -237,7 +237,7 @@
      % and values of any other variables stored in the varset.
      %
  :- func varset.select(varset(T), set(var(T))) = varset(T).
-:- pred varset.select(varset(T)::in, set(var(T))::in, varset(T)::out) is det.
+:- pred varset.select(set(var(T))::in, varset(T)::in, varset(T)::out) is det.

      % Given a varset and a list of variables, construct a new varset
      % containing one variable for each one in the list (and no others).
@@ -286,6 +286,9 @@

  %-----------------------------------------------------------------------------%

+varset.init = VS :-
+    varset.init(VS).
+
  varset.init(varset(VarSupply, Names, Values)) :-
      term.init_var_supply(VarSupply),
      map.init(Names),
@@ -298,35 +301,34 @@

  %-----------------------------------------------------------------------------%

-varset.new_var(VarSet0, Var, VarSet) :-
-    MaxId0 = VarSet0 ^ var_supply,
-    term.create_var(MaxId0, Var, MaxId),
-    VarSet = VarSet0 ^ var_supply := MaxId.
-
-varset.new_named_var(varset(MaxId0, Names0, Values), Name, Var,
-        varset(MaxId, Names, Values)) :-
+varset.new_var(Var, !VarSet) :-
+    MaxId0 = !.VarSet ^ var_supply,
      term.create_var(MaxId0, Var, MaxId),
-    map.set(Var, Name, Names0, Names).
+    !VarSet ^ var_supply := MaxId.

-varset.new_uniquely_named_var(varset(MaxId0, Names0, Values), Name, Var,
-        varset(MaxId, Names, Values)) :-
-    term.create_var(MaxId0, Var, MaxId),
+varset.new_named_var(Name, Var,
+        varset(!.MaxId, !.Names, Values), varset(!:MaxId, !:Names, Values)) :-
+    term.create_var(!.MaxId, Var, !:MaxId),
+    map.set(Var, Name, !Names).
+
+varset.new_uniquely_named_var(Name, Var,
+        varset(!.MaxId, !.Names, Values), varset(!:MaxId, !:Names, Values)) :-
+    term.create_var(!.MaxId, Var, !:MaxId),
      N = term.var_id(Var),
-    map.set(Var, string.format("%s_%d", [s(Name), i(N)]), Names0, Names).
+    map.set(Var, string.format("%s_%d", [s(Name), i(N)]), !Names).

-varset.new_maybe_named_var(varset(MaxId0, Names0, Values), MaybeName, Var,
-        varset(MaxId, Names, Values)) :-
-    term.create_var(MaxId0, Var, MaxId),
+varset.new_maybe_named_var(MaybeName, Var,
+        varset(!.MaxId, !.Names, Values), varset(!:MaxId, !:Names, Values)) :-
+    term.create_var(!.MaxId, Var, !:MaxId),
      (
-        MaybeName = no,
-        Names = Names0
+        MaybeName = no
      ;
          MaybeName = yes(Name),
-        map.set(Var, Name, Names0, Names)
+        map.set(Var, Name, !Names)
      ).

-varset.new_vars(VarSet0, NumVars, NewVars, VarSet) :-
-    varset.new_vars_2(NumVars, [], RevNewVars, VarSet0, VarSet),
+varset.new_vars(NumVars, NewVars, !VarSet) :-
+    varset.new_vars_2(NumVars, [], RevNewVars, !VarSet),
      % Return the new variables in order.
      list.reverse(RevNewVars, NewVars).

@@ -335,7 +337,7 @@

  varset.new_vars_2(NumVars, !RevNewVars, !VarSet) :-
      ( NumVars > 0 ->
-        varset.new_var(!.VarSet, Var, !:VarSet),
+        varset.new_var(Var, !VarSet),
          !:RevNewVars = [Var | !.RevNewVars],
          varset.new_vars_2(NumVars - 1, !RevNewVars, !VarSet)
      ; NumVars = 0 ->
@@ -346,17 +348,17 @@

  %-----------------------------------------------------------------------------%

-varset.delete_var(varset(MaxId, Names0, Values0), Var,
-        varset(MaxId, Names, Values)) :-
-    map.delete(Var, Names0, Names),
-    map.delete(Var, Values0, Values).
+varset.delete_var(Var, varset(MaxId, !.Names, !.Values),
+        varset(MaxId, !:Names, !:Values)) :-
+    map.delete(Var, !Names),
+    map.delete(Var, !Values).

  %-----------------------------------------------------------------------------%

-varset.delete_vars(VarSet, [], VarSet).
-varset.delete_vars(VarSet0, [Var | Vars], VarSet) :-
-    varset.delete_var(VarSet0, Var, VarSet1),
-    varset.delete_vars(VarSet1, Vars, VarSet).
+varset.delete_vars([], !VarSet).
+varset.delete_vars([Var | Vars], !VarSet) :-
+    varset.delete_var(Var, !VarSet),
+    varset.delete_vars(Vars, !VarSet).

  %-----------------------------------------------------------------------------%

@@ -379,10 +381,10 @@

  %-----------------------------------------------------------------------------%

-varset.name_var(VarSet0, Id, Name, VarSet) :-
-    Names0 = VarSet0 ^ var_names,
+varset.name_var(Id, Name, !VarSet) :-
+    Names0 = !.VarSet ^ var_names,
      map.set(Id, Name, Names0, Names),
-    VarSet = VarSet0 ^ var_names := Names.
+    !VarSet ^ var_names := Names.

  %-----------------------------------------------------------------------------%

@@ -409,24 +411,24 @@

  %-----------------------------------------------------------------------------%

-varset.bind_var(VarSet0, Id, Val, VarSet) :-
-    Values0 = VarSet0 ^ var_values,
+varset.bind_var(Id, Val, !VarSet) :-
+    Values0 = !.VarSet ^ var_values,
      map.set(Id, Val, Values0, Values),
-    VarSet = VarSet0 ^ var_values := Values.
+    !VarSet ^ var_values := Values.

  %-----------------------------------------------------------------------------%

-varset.bind_vars(VarSet0, Subst, VarSet) :-
+varset.bind_vars(Subst, !VarSet) :-
      map.to_assoc_list(Subst, VarTermList),
-    varset.bind_vars_2(VarTermList, VarSet0, VarSet).
+    varset.bind_vars_2(VarTermList, !VarSet).

  :- pred varset.bind_vars_2(assoc_list(var(T), term(T))::in, varset(T)::in,
      varset(T)::out) is det.

-varset.bind_vars_2([], VarSet, VarSet).
-varset.bind_vars_2([V - T | Rest], VarSet0, VarSet) :-
-    varset.bind_var(VarSet0, V, T, VarSet1),
-    varset.bind_vars_2(Rest, VarSet1, VarSet).
+varset.bind_vars_2([], !VarSet).
+varset.bind_vars_2([V - T | Rest], !VarSet) :-
+    varset.bind_var(V, T, !VarSet),
+    varset.bind_vars_2(Rest, !VarSet).

  %-----------------------------------------------------------------------------%

@@ -646,7 +648,7 @@

  %-----------------------------------------------------------------------------%

-varset.select(VarSet0, Vars, VarSet) :-
+varset.select(Vars, VarSet0, VarSet) :-
      VarSet0 = varset(Supply, VarNameMap0, Values0),
      map.select(VarNameMap0, Vars, VarNameMap),
      map.select(Values0, Vars, Values),
@@ -658,8 +660,7 @@
      % Create a new varset with the same number of variables.
      list.length(KeptVars, NumVars),
      varset.init(NewVarSet0),
-    varset.new_vars(NewVarSet0, NumVars,
-        NewVars0, NewVarSet1),
+    varset.new_vars(NumVars, NewVars0, NewVarSet0, NewVarSet1),

      % We need to sort the fresh variables, to ensure that the substitution
      % that we create below does not alter the relative ordering of the
@@ -674,14 +675,14 @@
  :- pred copy_var_names(assoc_list(var(T), string)::in, map(var(T), var(T))::in,
      varset(T)::in, varset(T)::out) is det.

-copy_var_names([], _Subst, NewVarSet, NewVarSet).
-copy_var_names([OldVar - Name | Rest], Subst, NewVarSet0, NewVarSet) :-
+copy_var_names([], _Subst, !NewVarSet).
+copy_var_names([OldVar - Name | Rest], Subst, !NewVarSet) :-
      ( map.search(Subst, OldVar, NewVar) ->
-        varset.name_var(NewVarSet0, NewVar, Name, NewVarSet1)
+        varset.name_var(NewVar, Name, !NewVarSet)
      ;
-        NewVarSet1 = NewVarSet0
+        true
      ),
-    copy_var_names(Rest, Subst, NewVarSet1, NewVarSet).
+    copy_var_names(Rest, Subst, !NewVarSet).

  %-----------------------------------------------------------------------------%

@@ -696,24 +697,23 @@
  varset.max_var(varset(VarSupply, _, _)) = term.var_supply_max_var(VarSupply).

  %-----------------------------------------------------------------------------%
+%:- end_module varset.
  %-----------------------------------------------------------------------------%
  % Ralph Becket <rwab1 at cl.cam.ac.uk> 30/04/99
  %   Function forms added.

-varset.init = VS :-
-    varset.init(VS).

-varset.delete_var(VS1, V) = VS2 :-
-    varset.delete_var(VS1, V, VS2).
+varset.delete_var(!.VS, V) = !:VS :-
+    varset.delete_var(V, !VS).

-varset.delete_vars(VS1, Vs) = VS2 :-
-    varset.delete_vars(VS1, Vs, VS2).
+varset.delete_vars(!.VS, Vs) = !:VS :-
+    varset.delete_vars(Vs, !VS).

  varset.vars(VS) = Vs :-
      varset.vars(VS, Vs).

-varset.name_var(VS1, V, S) = VS2 :-
-    varset.name_var(VS1, V, S, VS2).
+varset.name_var(!.VS, V, S) = !:VS :-
+    varset.name_var(V, S, !VS).

  varset.lookup_name(VS, V) = S :-
      varset.lookup_name(VS, V, S).
@@ -721,11 +721,11 @@
  varset.lookup_name(VS1, V, S) = S2 :-
      varset.lookup_name(VS1, V, S, S2).

-varset.bind_var(VS1, V, T) = VS2 :-
-    varset.bind_var(VS1, V, T, VS2).
+varset.bind_var(!.VS, V, T) = !:VS :-
+    varset.bind_var(V, T, !VS).

-varset.bind_vars(VS1, S) = VS2 :-
-    varset.bind_vars(VS1, S, VS2).
+varset.bind_vars(!.VS, S) = !:VS :-
+    varset.bind_vars(S, !VS).

  varset.lookup_vars(VS) = S :-
      varset.lookup_vars(VS, S).
@@ -745,8 +745,8 @@
  varset.ensure_unique_names(Vs, S1, VS1) = VS2 :-
      varset.ensure_unique_names(Vs, S1, VS1, VS2).

-varset.select(VS1, S) = VS2 :-
-    varset.select(VS1, S, VS2).
+varset.select(!.VS, S) = !:VS :-
+    varset.select(S, !VS).

-varset.coerce(VS1) = VS2 :-
-    varset.coerce(VS1, VS2).
+varset.coerce(!.VS) = !:VS :-
+    varset.coerce(!VS).
Index: samples/interpreter.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/samples/interpreter.m,v
retrieving revision 1.10
diff -u -r1.10 interpreter.m
--- samples/interpreter.m	10 Jan 2011 02:29:33 -0000	1.10
+++ samples/interpreter.m	4 May 2011 15:49:02 -0000
@@ -205,58 +205,57 @@

  :- pred unify(term::in, term::in, varset::in, varset::out) is semidet.

-unify(term.variable(X, _), term.variable(Y, _), VarSet0, VarSet) :-
-    ( varset.search_var(VarSet0, X, BindingOfX) ->
-        ( varset.search_var(VarSet0, Y, BindingOfY) ->
+unify(term.variable(X, _), term.variable(Y, _), !VarSet) :-
+    ( varset.search_var(!.VarSet, X, BindingOfX) ->
+        ( varset.search_var(!.VarSet, Y, BindingOfY) ->
              % Both X and Y already have bindings - just
              % unify the terms they are bound to.
-            unify(BindingOfX, BindingOfY, VarSet0, VarSet)
+            unify(BindingOfX, BindingOfY, !VarSet)
          ;
              % Y is a variable which hasn't been bound yet
-            apply_rec_substitution(BindingOfX, VarSet0, SubstBindingOfX),
+            apply_rec_substitution(BindingOfX, !.VarSet, SubstBindingOfX),
              ( SubstBindingOfX = term.variable(Y, _) ->
-                VarSet = VarSet0
+                true
              ;
-                \+ occurs(SubstBindingOfX, Y, VarSet0),
-                varset.bind_var(VarSet0, Y, SubstBindingOfX, VarSet)
+                \+ occurs(SubstBindingOfX, Y, !.VarSet),
+                varset.bind_var(Y, SubstBindingOfX, !VarSet)
              )
          )
      ;
-        ( varset.search_var(VarSet0, Y, BindingOfY2) ->
+        ( varset.search_var(!.VarSet, Y, BindingOfY2) ->
              % X is a variable which hasn't been bound yet.
-            apply_rec_substitution(BindingOfY2, VarSet0, SubstBindingOfY2),
+            apply_rec_substitution(BindingOfY2, !.VarSet, SubstBindingOfY2),
              ( SubstBindingOfY2 = term.variable(X, _) ->
-                VarSet = VarSet0
+                true
              ;
-                \+ occurs(SubstBindingOfY2, X, VarSet0),
-                varset.bind_var(VarSet0, X, SubstBindingOfY2, VarSet)
+                \+ occurs(SubstBindingOfY2, X, !.VarSet),
+                varset.bind_var(X, SubstBindingOfY2, !VarSet)
              )
          ;
              % Both X and Y are unbound variables -
              % bind one to the other.
              ( X = Y ->
-                VarSet = VarSet0
+                true
              ;
-                varset.bind_var(VarSet0, X,
-                        term.variable(Y, context_init), VarSet)
+                varset.bind_var(X, term.variable(Y, context_init), !VarSet)
              )
          )
      ).

-unify(term.variable(X, _), term.functor(F, As, C), VarSet0, VarSet) :-
-    ( varset.search_var(VarSet0, X, BindingOfX) ->
-        unify(BindingOfX, term.functor(F, As, C), VarSet0, VarSet)
+unify(term.variable(X, _), term.functor(F, As, C), !VarSet) :-
+    ( varset.search_var(!.VarSet, X, BindingOfX) ->
+        unify(BindingOfX, term.functor(F, As, C), !VarSet)
      ;
-        \+ occurs_list(As, X, VarSet0),
-        varset.bind_var(VarSet0, X, term.functor(F, As, C), VarSet)
+        \+ occurs_list(As, X, !.VarSet),
+        varset.bind_var(X, term.functor(F, As, C), !VarSet)
      ).

-unify(term.functor(F, As, C), term.variable(X, _), VarSet0, VarSet) :-
-    ( varset.search_var(VarSet0, X, BindingOfX) ->
-        unify(term.functor(F, As, C), BindingOfX, VarSet0, VarSet)
+unify(term.functor(F, As, C), term.variable(X, _), !VarSet) :-
+    ( varset.search_var(!.VarSet, X, BindingOfX) ->
+        unify(term.functor(F, As, C), BindingOfX, !VarSet)
      ;
-        \+ occurs_list(As, X, VarSet0),
-        varset.bind_var(VarSet0, X, term.functor(F, As, C), VarSet)
+        \+ occurs_list(As, X, !.VarSet),
+        varset.bind_var(X, term.functor(F, As, C), !VarSet)
      ).

  unify(term.functor(F, AsX, _), term.functor(F, AsY, _)) -->
Index: tests/debugger/interpreter.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/debugger/interpreter.m,v
retrieving revision 1.3
diff -u -r1.3 interpreter.m
--- tests/debugger/interpreter.m	1 Nov 2006 06:31:38 -0000	1.3
+++ tests/debugger/interpreter.m	4 May 2011 15:34:09 -0000
@@ -215,8 +215,8 @@
  			 	VarSet = VarSet0
  			;
  				\+ occurs(SubstBindingOfX, Y, VarSet0),
-				varset__bind_var(VarSet0, Y, SubstBindingOfX,
-					VarSet)
+				varset__bind_var(Y, SubstBindingOfX,
+					VarSet0, VarSet)
  			)
  		)
  	;
@@ -230,8 +230,8 @@
  				VarSet = VarSet0
  			;
  				\+ occurs(SubstBindingOfY2, X, VarSet0),
-				varset__bind_var(VarSet0, X, SubstBindingOfY2,
-					VarSet)
+				varset__bind_var(X, SubstBindingOfY2,
+					VarSet0, VarSet)
  			)
  		;
  			% both X and Y are unbound variables -
@@ -239,8 +239,8 @@
  			( X = Y ->
  				VarSet = VarSet0
  			;
-				varset__bind_var(VarSet0, X,
-					term.variable(Y, context_init), VarSet)
+				varset__bind_var(X,
+					term.variable(Y, context_init), VarSet0, VarSet)
  			)
  		)
  	).
@@ -253,7 +253,7 @@
  			VarSet)
  	;
  		\+ occurs_list(As, X, VarSet0),
-		varset__bind_var(VarSet0, X, term__functor(F, As, C), VarSet)
+		varset__bind_var(X, term__functor(F, As, C), VarSet0, VarSet)
  	).

  unify(term__functor(F, As, C), term__variable(X, _), VarSet0, VarSet) :-
@@ -264,7 +264,7 @@
  			VarSet)
  	;
  		\+ occurs_list(As, X, VarSet0),
-		varset__bind_var(VarSet0, X, term__functor(F, As, C), VarSet)
+		varset__bind_var(X, term__functor(F, As, C), VarSet0, VarSet)
  	).

  unify(term__functor(F, AsX, _), term__functor(F, AsY, _)) -->
Index: tests/general/interpreter.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/general/interpreter.m,v
retrieving revision 1.8
diff -u -r1.8 interpreter.m
--- tests/general/interpreter.m	1 Nov 2006 06:31:38 -0000	1.8
+++ tests/general/interpreter.m	4 May 2011 15:29:24 -0000
@@ -210,8 +210,8 @@
  			 	VarSet = VarSet0
  			;
  				\+ occurs(SubstBindingOfX, Y, VarSet0),
-				varset__bind_var(VarSet0, Y, SubstBindingOfX,
-					VarSet)
+				varset__bind_var(Y, SubstBindingOfX,
+					VarSet0, VarSet)
  			)
  		)
  	;
@@ -225,8 +225,8 @@
  				VarSet = VarSet0
  			;
  				\+ occurs(SubstBindingOfY2, X, VarSet0),
-				varset__bind_var(VarSet0, X, SubstBindingOfY2,
-					VarSet)
+				varset__bind_var(X, SubstBindingOfY2,
+					VarSet0, VarSet)
  			)
  		;
  			% both X and Y are unbound variables -
@@ -234,8 +234,9 @@
  			( X = Y ->
  				VarSet = VarSet0
  			;
-				varset__bind_var(VarSet0, X,
-					term.variable(Y, context_init), VarSet)
+				varset__bind_var(X,
+					term.variable(Y, context_init),
+					VarSet0, VarSet)
  			)
  		)
  	).
@@ -248,7 +249,7 @@
  			VarSet)
  	;
  		\+ occurs_list(As, X, VarSet0),
-		varset__bind_var(VarSet0, X, term__functor(F, As, C), VarSet)
+		varset__bind_var(X, term__functor(F, As, C), VarSet0, VarSet)
  	).

  unify(term__functor(F, As, C), term__variable(X, _), VarSet0, VarSet) :-
@@ -259,7 +260,7 @@
  			VarSet)
  	;
  		\+ occurs_list(As, X, VarSet0),
-		varset__bind_var(VarSet0, X, term__functor(F, As, C), VarSet)
+		varset__bind_var(X, term__functor(F, As, C), VarSet0, VarSet)
  	).

  unify(term__functor(F, AsX, _), term__functor(F, AsY, _)) -->
Index: tests/hard_coded/bigtest.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/bigtest.m,v
retrieving revision 1.2
diff -u -r1.2 bigtest.m
--- tests/hard_coded/bigtest.m	29 Mar 2006 08:07:59 -0000	1.2
+++ tests/hard_coded/bigtest.m	4 May 2011 15:32:31 -0000
@@ -33,7 +33,7 @@

  data(Eqns, max, Obj, Varset) :-
  	varset__init(Varset0 ),
-	varset__new_vars(Varset0, 80, Vars0, Varset),
+	varset__new_vars(80, Vars0, Varset0, Varset),
  	list__sort(Vars0, Vars),
  	list__map(mkeqn, Vars, Eqns),
  	list__map(mkobj, Vars, Obj).
Index: tests/hard_coded/deep_copy_bug.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/deep_copy_bug.m,v
retrieving revision 1.5
diff -u -r1.5 deep_copy_bug.m
--- tests/hard_coded/deep_copy_bug.m	5 Apr 2006 05:06:58 -0000	1.5
+++ tests/hard_coded/deep_copy_bug.m	4 May 2011 15:31:38 -0000
@@ -20,7 +20,7 @@
  test1 -->
  	{ Lambda = (pred(X::out) is nondet :-
  		varset__init(Varset0),
-		varset__new_vars(Varset0, 10, Vars, _),
+		varset__new_vars(10, Vars, Varset0, _),
  		list__member(X, Vars)
  	) },
  	{ solutions(Lambda, List) },
@@ -42,7 +42,7 @@
  :- mode foo(in, out) is nondet.
  foo(Blah, X) :-
  	varset__init(Varset0),
-	varset__new_vars(Varset0, 10, Vars, _),
+	varset__new_vars(10, Vars, Varset0, _),
  	list__member(X, Vars).

  :- pred test3(io__state::di, io__state::uo) is det.
Index: tests/hard_coded/lp.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/lp.m,v
retrieving revision 1.9
diff -u -r1.9 lp.m
--- tests/hard_coded/lp.m	3 May 2011 04:35:03 -0000	1.9
+++ tests/hard_coded/lp.m	4 May 2011 15:33:04 -0000
@@ -111,12 +111,12 @@
  		NEqns1 = [Eqn0|NEqns0]
  	;
  		Op0 = (=<),
-		varset__new_var(Varset0, Var, Varset1),
+		varset__new_var(Var, Varset0, Varset1),
  		Eqn1 = eqn([Var - 1.0|Coeffs0], (=), Const0),
  		NEqns1 = [Eqn1|NEqns0]
  	;
  		Op0 = (>=),
-		varset__new_var(Varset0, Var, Varset1),
+		varset__new_var(Var, Varset0, Varset1),
  		Eqn1 = eqn([Var - (-1.0)|Coeffs0], (=), Const0),
  		NEqns1 = [Eqn1|NEqns0]
  	),
Index: tests/hard_coded/pprint_test.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/pprint_test.m,v
retrieving revision 1.2
diff -u -r1.2 pprint_test.m
--- tests/hard_coded/pprint_test.m	3 May 2011 04:35:03 -0000	1.2
+++ tests/hard_coded/pprint_test.m	4 May 2011 15:30:32 -0000
@@ -18,8 +18,8 @@

  get_new_vars(Var1, Var2) :-
  	varset__init(VarSet0),
-	varset__new_var(VarSet0, Var1, VarSet1),
-	varset__new_var(VarSet1, Var2, _VarSet2).
+	varset__new_var(Var1, VarSet0, VarSet1),
+	varset__new_var(Var2, VarSet1, _VarSet2).

  main -->
  	{ get_new_vars(Var1, Var2) },
Index: tests/hard_coded/type_spec_ho_term.m
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/hard_coded/type_spec_ho_term.m,v
retrieving revision 1.1
diff -u -r1.1 type_spec_ho_term.m
--- tests/hard_coded/type_spec_ho_term.m	6 Jul 2001 14:14:11 -0000	1.1
+++ tests/hard_coded/type_spec_ho_term.m	4 May 2011 15:30:06 -0000
@@ -13,7 +13,7 @@

  main -->
  	{ varset__init(VarSet0 `with_type` varset) },
-	{ varset__new_vars(VarSet0, 4, Vars, _VarSet) },
+	{ varset__new_vars(4, Vars, VarSet0, _VarSet) },
  	{ map__from_corresponding_lists(Vars, ["a", "b", "c", "d"], Map) },
  	{ lookup_list(Map,
  		[list__index1_det(Vars, 1), list__index1_det(Vars, 3)],
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list