[m-rev.] for review: ho_inst_info clarification

Mark Brown mark at mercurylang.org
Mon Nov 16 21:23:02 AEDT 2015


On Thu, Nov 12, 2015 at 5:03 PM, Mark Brown <mark at mercurylang.org> wrote:
> On Thu, Nov 12, 2015 at 9:53 AM, Julien Fischer <jfischer at opturion.com> wrote:
>> I suggest 'none_or_default_func' since the term "default function mode"
>> is used pretty much throughout the system and introducing a second term
>> to describe the same concept is potentially confusing.
>
> Okay. The code already uses the name "standard" in some places, so
> I'll make all of them consistent.

The attached diff has been committed.

Mark
-------------- next part --------------
commit db464ca661ab471d2503a3f5098daf0d36f32faa
Author: Mark Brown <mark at mercurylang.org>
Date:   Mon Nov 16 20:39:15 2015 +1100

    Consistently refer to "default" function modes instead of "standard".

diff --git a/compiler/float_regs.m b/compiler/float_regs.m
index e80ccc3..16e239c 100644
--- a/compiler/float_regs.m
+++ b/compiler/float_regs.m
@@ -1370,7 +1370,7 @@ search_pred_inst_info(ModuleInfo, Inst, PredOrFunc, Arity, PredInstInfo) :-
         PredInstInfo = PredInstInfo0
     else
         PredOrFunc = pf_function,
-        PredInstInfo = pred_inst_info_standard_func_mode(Arity)
+        PredInstInfo = pred_inst_info_default_func_mode(Arity)
     ).
 
 :- pred search_pred_inst_info_2(module_info::in, mer_inst::in,
diff --git a/compiler/inst_match.m b/compiler/inst_match.m
index 3774a05..845d60d 100644
--- a/compiler/inst_match.m
+++ b/compiler/inst_match.m
@@ -722,14 +722,14 @@ greater_than_disregard_module_qual(ConsIdA, ConsIdB) :-
 ho_inst_info_matches_initial(HOInstInfoA, HOInstInfoB, MaybeType, !Info) :-
     (
         HOInstInfoB = none_or_default_func,
-        not ho_inst_info_is_nonstandard_func_mode(!.Info ^ imi_module_info,
+        not ho_inst_info_is_nondefault_func_mode(!.Info ^ imi_module_info,
             HOInstInfoA)
     ;
         HOInstInfoA = none_or_default_func,
         HOInstInfoB = higher_order(PredInstB),
         PredInstB = pred_inst_info(pf_function, ArgModes, _, _Det),
         Arity = list.length(ArgModes),
-        PredInstA = pred_inst_info_standard_func_mode(Arity),
+        PredInstA = pred_inst_info_default_func_mode(Arity),
         pred_inst_matches_2(PredInstA, PredInstB, MaybeType, !Info)
     ;
         HOInstInfoA = higher_order(PredInstA),
@@ -1018,7 +1018,7 @@ inst_matches_final_3(InstA, InstB, MaybeType, !Info) :-
         InstA = ground(UniqA, HOInstInfoA),
         InstB = bound(UniqB, InstResultsB, BoundInstsB),
         ModuleInfo = !.Info ^ imi_module_info,
-        not ho_inst_info_is_nonstandard_func_mode(ModuleInfo, HOInstInfoA),
+        not ho_inst_info_is_nondefault_func_mode(ModuleInfo, HOInstInfoA),
         unique_matches_final(UniqA, UniqB),
         inst_results_bound_inst_list_is_ground_mt(InstResultsB, BoundInstsB,
             MaybeType, ModuleInfo),
@@ -1069,14 +1069,14 @@ inst_matches_final_3(InstA, InstB, MaybeType, !Info) :-
 ho_inst_info_matches_final(HOInstInfoA, HOInstInfoB, MaybeType, !Info) :-
     (
         HOInstInfoB = none_or_default_func,
-        not ho_inst_info_is_nonstandard_func_mode(!.Info ^ imi_module_info,
+        not ho_inst_info_is_nondefault_func_mode(!.Info ^ imi_module_info,
             HOInstInfoA)
     ;
         HOInstInfoA = none_or_default_func,
         HOInstInfoB = higher_order(PredInstB),
         PredInstB = pred_inst_info(pf_function, ArgModes, _, _Det),
         Arity = list.length(ArgModes),
-        PredInstA = pred_inst_info_standard_func_mode(Arity),
+        PredInstA = pred_inst_info_default_func_mode(Arity),
         pred_inst_matches_2(PredInstA, PredInstB, MaybeType, !Info)
     ;
         HOInstInfoA = higher_order(PredInstA),
@@ -1259,7 +1259,7 @@ ho_inst_info_matches_binding(HOInstInfoA, HOInstInfoB, MaybeType,
         HOInstInfoB = higher_order(PredInstB),
         PredInstB = pred_inst_info(pf_function, ArgModes, _, _Det),
         Arity = list.length(ArgModes),
-        PredInstA = pred_inst_info_standard_func_mode(Arity),
+        PredInstA = pred_inst_info_default_func_mode(Arity),
         pred_inst_matches_mt(PredInstA, PredInstB, MaybeType, ModuleInfo)
     ;
         HOInstInfoA = higher_order(PredInstA),
diff --git a/compiler/inst_util.m b/compiler/inst_util.m
index 027467e..a4a30b0 100644
--- a/compiler/inst_util.m
+++ b/compiler/inst_util.m
@@ -118,14 +118,14 @@
 
 %---------------------------------------------------------------------------%
 
-    % inst_contains_nonstandard_func_mode(Inst, ModuleInfo) succeeds iff the
+    % inst_contains_nondefault_func_mode(Inst, ModuleInfo) succeeds iff the
     % inst contains a higher-order function inst that does not match the
-    % standard function mode `(in, ..., in) = out is det'.
+    % default function mode `(in, ..., in) = out is det'.
     % E.g. this predicate fails for "func(in) = uo" because that matches the
-    % standard func mode "func(in) = out", even though it isn't the same as
-    % the standard func mode.
+    % default func mode "func(in) = out", even though it isn't the same as
+    % the default func mode.
     %
-:- pred inst_contains_nonstandard_func_mode(module_info::in, mer_inst::in)
+:- pred inst_contains_nondefault_func_mode(module_info::in, mer_inst::in)
     is semidet.
 
     % Succeed iff the inst is any or contains any.
@@ -138,20 +138,20 @@
     is semidet.
 
     % Succeed iff the first argument is a function pred_inst_info
-    % whose mode does not match the standard func mode.
+    % whose mode does not match the default func mode.
     %
-:- pred pred_inst_info_is_nonstandard_func_mode(module_info::in,
+:- pred pred_inst_info_is_nondefault_func_mode(module_info::in,
     pred_inst_info::in) is semidet.
 
     % Succeed iff the first argument is a function ho_inst_info
-    % whose mode does not match the standard func mode.
+    % whose mode does not match the default func mode.
     %
-:- pred ho_inst_info_is_nonstandard_func_mode(module_info::in,
+:- pred ho_inst_info_is_nondefault_func_mode(module_info::in,
     ho_inst_info::in) is semidet.
 
-    % Return the standard mode for a function of the given arity.
+    % Return the default mode for a function of the given arity.
     %
-:- func pred_inst_info_standard_func_mode(arity) = pred_inst_info.
+:- func pred_inst_info_default_func_mode(arity) = pred_inst_info.
 
     % Return true if the given inst may restrict the set of function symbols
     % that may be successfully unified with the variable that has this inst.
@@ -2015,13 +2015,13 @@ merge_ho_inst_info(HOInstInfoA, HOInstInfoB, HOInstInfo, !ModuleInfo) :-
         else
             % If either is a function inst with non-default modes,
             % don't allow the higher-order information to be lost.
-            not pred_inst_info_is_nonstandard_func_mode(!.ModuleInfo, PredA),
-            not pred_inst_info_is_nonstandard_func_mode(!.ModuleInfo, PredB),
+            not pred_inst_info_is_nondefault_func_mode(!.ModuleInfo, PredA),
+            not pred_inst_info_is_nondefault_func_mode(!.ModuleInfo, PredB),
             HOInstInfo = none_or_default_func
         )
     else
-        not ho_inst_info_is_nonstandard_func_mode(!.ModuleInfo, HOInstInfoA),
-        not ho_inst_info_is_nonstandard_func_mode(!.ModuleInfo, HOInstInfoB),
+        not ho_inst_info_is_nondefault_func_mode(!.ModuleInfo, HOInstInfoA),
+        not ho_inst_info_is_nondefault_func_mode(!.ModuleInfo, HOInstInfoB),
         HOInstInfo = none_or_default_func
     ).
 
@@ -2201,18 +2201,18 @@ bound_inst_list_merge(BoundInstsA, BoundInstsB, MaybeType, BoundInsts,
 %---------------------------------------------------------------------------%
 %---------------------------------------------------------------------------%
 
-inst_contains_nonstandard_func_mode(ModuleInfo, Inst) :-
+inst_contains_nondefault_func_mode(ModuleInfo, Inst) :-
     set.init(Expansions0),
-    inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, Expansions0) = yes.
+    inst_contains_nondefault_func_mode_2(ModuleInfo, Inst, Expansions0) = yes.
 
-:- func inst_contains_nonstandard_func_mode_2(module_info, mer_inst,
+:- func inst_contains_nondefault_func_mode_2(module_info, mer_inst,
     set(inst_name)) = bool.
 
-inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, !.Expansions)
+inst_contains_nondefault_func_mode_2(ModuleInfo, Inst, !.Expansions)
         = ContainsNonstd :-
     (
         Inst = ground(_, HOInstInfo),
-        ( if ho_inst_info_is_nonstandard_func_mode(ModuleInfo, HOInstInfo) then
+        ( if ho_inst_info_is_nondefault_func_mode(ModuleInfo, HOInstInfo) then
             ContainsNonstd = yes
         else
             ContainsNonstd = no
@@ -2226,7 +2226,7 @@ inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, !.Expansions)
             ( InstResults = inst_test_results(_, _, _, _, _, _)
             ; InstResults = inst_test_no_results
             ),
-            ContainsNonstd = bound_inst_list_contains_nonstandard_func_mode(
+            ContainsNonstd = bound_inst_list_contains_nondefault_func_mode(
                 ModuleInfo, BoundInsts, !.Expansions)
         )
     ;
@@ -2239,12 +2239,12 @@ inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, !.Expansions)
         else
             set.insert(InstName, !Expansions),
             inst_lookup(ModuleInfo, InstName, SubInst),
-            ContainsNonstd = inst_contains_nonstandard_func_mode_2(ModuleInfo,
+            ContainsNonstd = inst_contains_nondefault_func_mode_2(ModuleInfo,
                 SubInst, !.Expansions)
         )
     ;
         Inst = constrained_inst_vars(_, SubInst),
-        ContainsNonstd = inst_contains_nonstandard_func_mode_2(ModuleInfo,
+        ContainsNonstd = inst_contains_nondefault_func_mode_2(ModuleInfo,
             SubInst, !.Expansions)
     ;
         ( Inst = free
@@ -2261,55 +2261,55 @@ inst_contains_nonstandard_func_mode_2(ModuleInfo, Inst, !.Expansions)
         ContainsNonstd = no
     ).
 
-:- func inst_list_contains_nonstandard_func_mode(module_info, list(mer_inst),
+:- func inst_list_contains_nondefault_func_mode(module_info, list(mer_inst),
     set(inst_name)) = bool.
 
-inst_list_contains_nonstandard_func_mode(_ModuleInfo, [], _Expansions) = no.
-inst_list_contains_nonstandard_func_mode(ModuleInfo, [Inst | Insts],
+inst_list_contains_nondefault_func_mode(_ModuleInfo, [], _Expansions) = no.
+inst_list_contains_nondefault_func_mode(ModuleInfo, [Inst | Insts],
         Expansions) = ContainsNonstd :-
-    HeadContainsNonstd = inst_contains_nonstandard_func_mode_2(ModuleInfo,
+    HeadContainsNonstd = inst_contains_nondefault_func_mode_2(ModuleInfo,
         Inst, Expansions),
     (
         HeadContainsNonstd = yes,
         ContainsNonstd = yes
     ;
         HeadContainsNonstd = no,
-        ContainsNonstd = inst_list_contains_nonstandard_func_mode(ModuleInfo,
+        ContainsNonstd = inst_list_contains_nondefault_func_mode(ModuleInfo,
             Insts, Expansions)
     ).
 
-:- func bound_inst_list_contains_nonstandard_func_mode(module_info,
+:- func bound_inst_list_contains_nondefault_func_mode(module_info,
     list(bound_inst), set(inst_name)) = bool.
 
-bound_inst_list_contains_nonstandard_func_mode(_ModuleInfo, [], _Expansions)
+bound_inst_list_contains_nondefault_func_mode(_ModuleInfo, [], _Expansions)
         = no.
-bound_inst_list_contains_nonstandard_func_mode(ModuleInfo,
+bound_inst_list_contains_nondefault_func_mode(ModuleInfo,
         [BoundInst | BoundInsts], Expansions) = ContainsNonstd :-
     BoundInst = bound_functor(_ConsId, ArgInsts),
-    HeadContainsNonstd = inst_list_contains_nonstandard_func_mode(ModuleInfo,
+    HeadContainsNonstd = inst_list_contains_nondefault_func_mode(ModuleInfo,
         ArgInsts, Expansions),
     (
         HeadContainsNonstd = yes,
         ContainsNonstd = yes
     ;
         HeadContainsNonstd = no,
-        ContainsNonstd = bound_inst_list_contains_nonstandard_func_mode(
+        ContainsNonstd = bound_inst_list_contains_nondefault_func_mode(
             ModuleInfo, BoundInsts, Expansions)
     ).
 
 %---------------------------------------------------------------------------%
 
-pred_inst_info_is_nonstandard_func_mode(ModuleInfo, PredInstInfo) :-
+pred_inst_info_is_nondefault_func_mode(ModuleInfo, PredInstInfo) :-
     PredInstInfo = pred_inst_info(pf_function, ArgModes, _, _),
     Arity = list.length(ArgModes),
     not pred_inst_matches(PredInstInfo,
-        pred_inst_info_standard_func_mode(Arity), ModuleInfo).
+        pred_inst_info_default_func_mode(Arity), ModuleInfo).
 
-ho_inst_info_is_nonstandard_func_mode(ModuleInfo, HOInstInfo) :-
+ho_inst_info_is_nondefault_func_mode(ModuleInfo, HOInstInfo) :-
     HOInstInfo = higher_order(PredInstInfo),
-    pred_inst_info_is_nonstandard_func_mode(ModuleInfo, PredInstInfo).
+    pred_inst_info_is_nondefault_func_mode(ModuleInfo, PredInstInfo).
 
-pred_inst_info_standard_func_mode(Arity) = PredInstInfo :-
+pred_inst_info_default_func_mode(Arity) = PredInstInfo :-
     in_mode(InMode),
     out_mode(OutMode),
     ArgModes = list.duplicate(Arity - 1, InMode) ++ [OutMode],
diff --git a/compiler/mode_util.m b/compiler/mode_util.m
index 3c799a1..f88fde0 100644
--- a/compiler/mode_util.m
+++ b/compiler/mode_util.m
@@ -1862,13 +1862,13 @@ normalise_inst(ModuleInfo, Type, Inst0, NormalisedInst) :-
             else
                 fail
             ),
-            not inst_contains_nonstandard_func_mode(ModuleInfo, Inst)
+            not inst_contains_nondefault_func_mode(ModuleInfo, Inst)
         then
             NormalisedInst = ground(Uniq, none_or_default_func)
         else if
             inst_is_ground(ModuleInfo, Inst),
             not inst_is_clobbered(ModuleInfo, Inst),
-            not inst_contains_nonstandard_func_mode(ModuleInfo, Inst)
+            not inst_contains_nondefault_func_mode(ModuleInfo, Inst)
         then
             NormalisedInst = ground(shared, none_or_default_func)
         else
diff --git a/compiler/modecheck_call.m b/compiler/modecheck_call.m
index b8b8854..ac05a9a 100644
--- a/compiler/modecheck_call.m
+++ b/compiler/modecheck_call.m
@@ -240,7 +240,7 @@ modecheck_higher_order_call(PredOrFunc, PredVar, Args0, Args, Modes, Det,
             mode_info_get_var_types(!.ModeInfo, VarTypes),
             lookup_var_type(VarTypes, PredVar, Type),
             type_is_higher_order_details(Type, _, pf_function, _, ArgTypes),
-            PredInstInfo = pred_inst_info_standard_func_mode(
+            PredInstInfo = pred_inst_info_default_func_mode(
                 list.length(ArgTypes))
         ),
         PredInstInfo = pred_inst_info(PredOrFunc, ModesPrime, _, DetPrime),
diff --git a/compiler/pd_util.m b/compiler/pd_util.m
index 4c3d122..d70d558 100644
--- a/compiler/pd_util.m
+++ b/compiler/pd_util.m
@@ -938,7 +938,7 @@ bound_inst_list_MSG(Xs, Ys, Expansions, ModuleInfo, Uniq, BoundInsts, Inst) :-
             NewInst = bound(unique, inst_test_no_results, BoundInsts),
             inst_is_unique(ModuleInfo, NewInst)
         ),
-        \+ inst_contains_nonstandard_func_mode(ModuleInfo,
+        \+ inst_contains_nondefault_func_mode(ModuleInfo,
             bound(shared, inst_test_no_results, BoundInsts)),
         Inst = ground(Uniq, none_or_default_func)
     ).
diff --git a/compiler/prog_data.m b/compiler/prog_data.m
index aed7947..71401b6 100644
--- a/compiler/prog_data.m
+++ b/compiler/prog_data.m
@@ -2023,8 +2023,8 @@ get_type_kind(kinded_type(_, Kind)) = Kind.
     % whose results we can consider adding, together with the names of the
     % predicates that could use them.
     %
-    % Does the inst contain a nonstandard func mode?
-    %   inst_contains_nonstandard_func_mode
+    % Does the inst contain a nondefault func mode?
+    %   inst_contains_nondefault_func_mode
     %
     % Does the inst contain any part that is uniq or mostly_uniq?
     %   make_shared_inst


More information about the reviews mailing list