[m-users.] Determinism woes...
emacstheviking
objitsu at gmail.com
Fri Jul 5 08:23:25 AEST 2019
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20190704/fde4fa33/attachment.html>
More information about the users
mailing list