[m-users.] Determinism woes...

Richard O'Keefe raoknz at gmail.com
Fri Jul 5 08:40:40 AEST 2019


char_type(')', p_open).
char_type('(', p_close).
char_type(_, c_general).

')' matches two clauses, the first and last.
'(' matches two clauses, the second and last.

On Fri, 5 Jul 2019 at 10:24, emacstheviking <objitsu at gmail.com> wrote:

> To paraphrase Neo, "I know Prolog".
>
> but I don't know Mercury and I am struggling to figure out this error....I
> am porting some old SWI code and it boils down to the fact that I obvuisly
> don't truly understand what "det" means! Here is the code both as discrete
> disjunctive clauses and a single big disjunct:
>
> :- pred char_type(char::in, chartype::out) is det.
>
> char_type(')', p_open).
> char_type('(', p_close).
> char_type(_, c_general).
>
> char_type(C, T) :-
>     (
>         C = '(', T = p_open
>     ;   C = ')', T = p_close
>     ;   C = _,   T = c_general
>     ).
>
> and here is the compiler output:
>
> fl1.m:049: In `char_type'(in, out):
> fl1.m:049:   error: determinism declaration not satisfied.
> fl1.m:049:   Declared `det', inferred `multi'.
> fl1.m:056:   Disjunction has multiple clauses with solutions.
>
> Now...I understand why (I think) this happens: it's because the final
> matching disjuny can match more than one character value hence the multiple
> (multi) classification by the compiler BUT he calling loop seeks merely to
> convert a character into a character type.
>
> Is this "cc_multi" in disguise as if the character is not one of the ones
> explicitly tested for then I will commit to the first choice as it will be
> a "general" character i.e. one with no special meaning to my little lexer.
>
> Thank you,
> Sean.
>
> _______________________________________________
> users mailing list
> users at lists.mercurylang.org
> https://lists.mercurylang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190705/c0ad3f07/attachment-0001.html>


More information about the users mailing list