[m-rev.] for review: new style warning options

Julien Fischer jfischer at opturion.com
Sat Oct 15 17:05:46 AEDT 2016


Hi Zoltan,

On Fri, 14 Oct 2016, Zoltan Somogyi wrote:

> For review by anyone.
>
> Add options to check the ordering of module contents.
> 
> One option, --warn-non-contiguous-decls, generates warnings if the
> mode declarations of a predicate or function aren't in a contiguous block
> immediately following the pred or func declaration. Since this is a rare
> kind of "style error", this option is enabled by default.
> 
> Two options, --warn-inconsistent-pred-order-clauses and
> --warn-inconsistent-pred-order-foreign-procs, warn about inconsistencies
> between (a) the order in which predicates (and functions) are declared,
> and (b) the order in which they are defined. The two options differ in
> their scope. The latter applies to all predicates and functions defined
> in the module, while the former applies only to those whose definitions
> include Mercury clauses.
> 
> Since an exported predicate or function may need nonexported auxiliary
> predicates and/or functions, imposing a single order the declarations and
> definitions of *all* the predicates and functions in a module is not a good
> idea. Instead, both options divide the predicates and functions defined
> in a module two groups, the exported and the nonexported, and expect
> a consistent order only within each group.
> 
> The result is output that looks like this:
>
>     time.m:021: Warning: the order of the declarations and definitions of the
>     time.m:021:   exported predicates is inconsistent, as shown by this diff:
>     time.m:021:
>     time.m:021:   --- declaration order
>     time.m:021:   +++ definition order
>     time.m:021:   @@ -1,7 +1,7 @@
>     time.m:021:    predicate `clock'/3
>     time.m:021:   -predicate `time'/3
>     time.m:021:    predicate `times'/4
>     time.m:021:    function `clk_tck'/0
>     time.m:021:   +predicate `time'/3
>     time.m:021:    function `difftime'/2
>     time.m:021:    predicate `localtime'/4
>     time.m:021:    function `localtime'/1

That looks fine.  I have one suggestion, there should be an option that disables
all other style warning options, --no-style-warnings.

Julien.


More information about the reviews mailing list