Re: [m-users.] Compiler cannot infer determinism det when exhaustively pattern matching on a constant?
Julien Fischer <[email protected]> Thu, 1 Aug 2024 14:33:17 +1000
| Newsgroups | gmane.comp.lang.mercury.general |
|---|---|
| Message-ID | <CAFFSLtjOew0iPXokfFVktCxNO7WJ2T5chhnAnwALGN7tRwbFnw@mail.gmail.com> |
On Thu, 1 Aug 2024 at 13:04, Anders Lundstedt <[email protected]> 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. _______________________________________________ users mailing list [email protected] https://lists.mercurylang.org/listinfo/users