Re: [m-users.] Compiler cannot infer determinism det when exhaustively pattern matching on a constant?
Julien Fischer <[email protected]> Thu, 1 Aug 2024 14:34:37 +1000
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <CAFFSLtgXiyHECNehpoxC+miJK2vk2kuCvYBicA_ZbCWFTobboQ@mail.gmail.com> |
On Thu, 1 Aug 2024 at 13:46, Anders Lundstedt <[email protected]> wrote: > > 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)? Ignore me there, I'm talking nonsense. The issue, as I mentioned elsewhere, is the function call to c/0. Julien. _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users