Singleton warnings, multitons warning

I am wondering if pred5 should also raise a warning because the same variable name is used as-is and “underscored”. What do you think?

a :- pred1(Flags).                 % singleton
a :- pred2(_Flags).                % no warning
a :- pred3(_Flags, _Flags).        % "multiton"
a :- pred4(_Flags, Flags).         % singleton
a :- pred5(_Flags, Flags, Flags).  % should this raise a warning?

Surely the current behavior is on purpose. Flags and _Flags have no relation to one another. Thus, in pred5 there is _Flags as a singleton, which is fine and two instances of Flags, which is fine too.

Of course, one could argue that if _Name is there only to avoid a singleton warning it is a good idea to have a warning if both _Name and Name appear in a clause. This would require another type of message :frowning:

The main question is whether this is a common (enough) problem to justify the check and explain it? Experiences?

I fall into this trap from time to time. Not super often, though.

(This is why I asked the forum, to get an impression if it is relevant.)

1 Like

I’ve made this mistake from time to time, or something similar, typically when I’m modifying existing code by adding parameters or an intermediate goal, especially for debugging. Next time I encounter it, I’ll try to remember to write down the sequence that led to the mistake. :wink: