|Did you know ...||Search Documentation:|
|Warning: (File:Line): Singleton variables: [...]|
This is a warning to help you with two common mistakes:
It indicates that there is one or more variable in the clause that
appears only once. This is never necessary as the first appearance of a
variable always succeeds with a successful binding. If this binding is
not used anywhere, nothing happens. You may compare it to gcc's warning
statement has no effect''.
But, what else do I place there? Prolog has the anonymous variable named
_ for this purpose. This variable has `no name', unifies to anything
without any effect. If
_ appears multiple times in the same term,
they refer to distinct variables.
But, how do I document what I ignore? Prolog systems won't complain on
variables that start with an underscore. Thus, the variable
won't be reported if it is singleton. Note however that where two
_ are distinct variables, two appearances of
_Country are not: they are the same variable.
But, the program I received has tons. What now? For this emergency there is the directive style_check/1. The code below compiles silently.
:- style_check(-singleton). better('SWI-Prolog', AnyOtherProlog?).