On 07/11/2017 01:37 AM, Barb Knox wrote:
>
> It's not idiomatic but structural. In each branch, both A and B only
> occur once.
>
>> or can I make the warnings go away with some special spell?
>
> You can replace A and B with _ or with _A and _B respectively.
Unfortunately, _A doesn't work. That is because there are two separate
analysers. read_term/2,3 does syntactic analysis and reports two _A
in a term as a warning. The compiler sees an A that doesn't communicate
information because the other A is in a different branch as something to
warn again.
So, _ works fine. There is one other escape: _<digit>... are variables
that are not subject to singleton checking (to avoid reporting on such
generated variable names). So, you can write _0A or something like
that. I also use that in some cases for debug/3 statements like this:
x(...., A),
debug(channel, 'Nice ~p', [A]).
That code raises a warning when compiled using -O as that removes
the debug statement. If you use _A you also get a warning. Using
_0A is the only `solution'.
Cheers --- Jan