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

Anders Lundstedt <[email protected]> Thu, 1 Aug 2024 05:45:42 +0200
Newsgroups gmane.comp.lang.mercury.general
Message-ID <CANGMbabZUEBzC-Feivuox1jVHCWjVu4mzwbbBDvhvtCq5pt2Qg@mail.gmail.com>
Another minor thing:

> > ...
> > % accepted by compiler
> > p1(A, B) :- (A = c1, B = c2) ; (A = c2, B = c1).
> > ...
> > % compiler error
> > p3(A) :- (c = c1, A = c2) ; (c = c2, A = c1).
>
> 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
>
> By that criterion, p1 is a switch (and hence det) where A is the bound variable.
> The disjunct in p3 is not a switch because each disjunct begins with a
> conjunction.

In what sense does each disjunct of p3 begin with a conjunction while
each disjunct of p1 does not? Is not the problem rather that each
disjunct of p3 has not “near its start a unification that tests the
same bound variable against a different function symbol” (which each
disjunct of p1 has)?
_______________________________________________
users mailing list
[email protected]
https://lists.mercurylang.org/listinfo/users