Previous Up Next

15.2  Heuristic Program Checker

The Heuristic Program Checking tool generates warning messages for dubious programming constructs and violation of naming conventions for an ECLiPSe source module or file. It is loaded as follows:

:- lib(lint).

The heuristic rules currently enforced are based on the style guide of Appendix E. These rules are somewhat limited in scope. The library is distributed as source and serves to provide a framework for the addition of a more comprehensive set of rules that are tailored to each individual developer.

Consider the following typographic mistakes in the n-queens example:

queen(Data, Out) :-
        qperm(Datas, Out),

n0diag([], _, _).

The tool is invoked using the lint/1 predicate with the source file specified as an atom or string:

?- lint(queen).

--- File /tmp/queen.ecl, line 4:
Singleton variables: [Data, Datas]

--- File /tmp/queen.ecl, line 22:
Questionable predicate name: n0diag

Yes (0.01s cpu)

The checker identifies Data and Datas as being singleton variables and is dubious of the n0diag predicate name. Both are the result of programmer error, Datas should read Data and n0diag as nodiag. The lint/2 predicate allows a list of options to be specified that turn on and off the heuristic rules.

Previous Up Next