[m-rev.] for review: printing in,out,di,uo

Julien Fischer jfischer at opturion.com
Sat Jun 22 13:59:31 AEST 2019


Hi Zoltan,

On Fri, 21 Jun 2019, Zoltan Somogyi wrote:

> For review by anyone.

> Print the in,out,di,do modes as such.

I would be inclined to do the same for all of the basic modes.
(Certainly mdi, muo and ui would count as fairly high frequency modes in
Opturion's code base.)

> compiler/parse_tree_out_inst.m:
>     When writing out modes for debugging purposes (in error messages,
>     or in HLDS dumps), print "in" instead of "(free >> ground)"
>     and similarly for out, di and uo.
>
>     When writing out modes for use by other invocations of the Mercury
>     compiler, keep the output as it was.
> 
> compiler/mode_errors.m:
>     When printing mode declarations, let the caller specify whether
>     we are intending the output for humans or not.
> 
> compiler/mode_errors.m:
> compiler/add_clause.m:
>     Specify this parameter: generate output for machines when
>     the exact form of the mode may be relevant, and for humans otherwise.
> 
> compiler/make_hlds_error.m:
>     Delete two unused predicates, which were near-exact duplicates
>     of (a) the predicate touched by the change to add_clause.m,
>     and (b) its caller.
> 
> tests/invalid/bug410.err_exp:
> tests/invalid/modes_erroneous.err_exp:
>     Expect the human-friendly forms of in and out.

...

> diff --git a/compiler/parse_tree_out_inst.m b/compiler/parse_tree_out_inst.m
> index 4db070854..abf2a742c 100644
> --- a/compiler/parse_tree_out_inst.m
> +++ b/compiler/parse_tree_out_inst.m
> @@ -557,19 +557,68 @@ mercury_mode_to_string(Lang, InstVarSet, Mode) = String :-
>  mercury_format_mode(Lang, InstVarSet, Mode, !U) :-
>      (
>          Mode = from_to_mode(InstA, InstB),
> -        % Output higher-order pred and func modes in a nice format.
> -        ( if
> -            InstA = ground(_Uniq, higher_order(
> -                pred_inst_info(_PredOrFunc, _Modes, _, _Det))),
> -            InstB = InstA
> -        then
> -            mercury_format_inst(Lang, InstVarSet, InstA, !U)
> -        else
> -            add_string("(", !U),
> -            mercury_format_inst(Lang, InstVarSet, InstA, !U),
> -            add_string(" >> ", !U),
> -            mercury_format_inst(Lang, InstVarSet, InstB, !U),
> -            add_string(")", !U)
> +        % In the general case, we output this mode as "(InstA >> InstB)".
> +        % 
> +        % we special case the four modes (in, out, di and uo)

s/we/We/

> +        % because of their very high frequency, and higher-order
> +        % pred and func modes, because their (InstA >> InstB) forms
> +        % can be very hard to read.

That looks fine otherwise.

Julien.


More information about the reviews mailing list