[m-users.] Compiler cannot infer determinism det when exhaustively pattern matching on a constant?

Julien Fischer jfischer at opturion.com
Thu Aug 1 14:33:17 AEST 2024


On Thu, 1 Aug 2024 at 13:04, Anders Lundstedt
<mercury-users at anderslundstedt.se> wrote:
>
> > According to the algorithm that the compiler uses to detect switches:
> >
> >         A disjunction is a switch if each disjunct has near its start
> > a unification
> >         that tests the same bound variable against a different function symbol
>
> Thanks for this! Just out of curiosity: what is the exact meaning of
> “near its start” here?

I quoted the above from section 7.2 of the reference manual
"Determinism checking and inference".
It goes on to describe what "near" means.

> > If you rewrite p3 to be:
> >
> >      p3(A) :- (c = c1, A = c2 ; c = c2, A = c1)
> >
> > it will also not be detected as a switch
>
> Did you mean something else or is this rewrite really more than
> syntactically different from my p3? My p3:
>
> p3(A) :- (c = c1, A = c2) ; (c = c2, A = c1).
>
> (Remove the inner parentheses to get your rewrite. But the comma bind
> more tightly than the semicolon and thus there should be no
> difference?)

Correct, there is no difference.

Julien.


More information about the users mailing list