- +Style enables a style check
- -Style disables a style check
- ?(Style) queries a style check (note the brackets). If Style is unbound, all active style check options are returned on backtracking.
Loading a file using load_files/2 or one of its derived predicates reset the style checking options to their value before loading the file, scoping the option to the remainder of the file and all files loaded after changing the style checking.
- The predicate read_clause/3 (used by the compiler to read source code) warns on variables appearing only once in a term (clause) which have a name not starting with an underscore. See section 188.8.131.52 for details on variable handling and warnings.
- This warning is generated by the compiler for BIPs (built-in predicates)
that are inlined by the compiler and for which the compiler can prove
that they are meaningless. An example is using ==/2
against a not-yet-initialised variable as illustrated in the example
below. This comparison is always
always_false(X) :- X == Y, write(Y).
- Verifies that if a variable is introduced in a branch and used
after the branch, it is introduced in all branches. This code
aims at bugs following the skeleton below, where
p(Next)may be called with Next unbound.
p(Arg) :- ( Cond -> Next = value1 ; true ), p(Next).
If a variable V is intended to be left unbound, one can use
V=_. This construct is removed by the compiler and thus has no implications for the performance of your program.
This check was suggested together with semantic singleton checking. The SWI-Prolog libraries contain about a hundred clauses that are triggered by this style check. Unlike semantic singleton analysis, only a tiny fraction of these clauses proofed faulty. In most cases, the branches failing to bind the variable fail or raise an exception or the caller handles the case where the variable is unbound. The status of this style check is unclear. It might be removed in the future or it might be enhanced with a deeper analysis to be more precise.
- Warn if the clauses for a predicate are not together in the same source file. It is advised to disable the warning for discontiguous predicates using the discontiguous/1 directive.
- Warn on atoms and variable names holding non-ASCII characters that are not quoted. See also section 184.108.40.206.