<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Zoltan, your replies have always helped and continue to do so.<div class=""><br class=""></div><div class=""><span style="font-family: CourierNewPSMT; font-size: 16px;" class="">If by "one" you mean one determinism declaration, they why do you</span><br style="font-family: CourierNewPSMT; font-size: 16px;" class=""><span style="font-family: CourierNewPSMT; font-size: 16px;" class="">"change one and recompile"?</span><br class=""><div><br class=""></div><div>The answer; simple frustration at being fully cognisant of my own ignorance, that’s why.</div><div><br class=""></div><div>I —understand— the reasons why it is telling me I am wrong but then chaos seems to erupt inside my head. It’s —my— decision as to the determinism of the code I write, IIUIC that’s the point of declaring it, then the compiler tells me otherwise when it knows better (often).</div><div><br class=""></div><div>As for using solutions/1, it crossed my mind but for me that’s a biiig code smell and I refused to do it.</div><div><br class=""></div><div>Part of my confusion is understanding what it means to have more than one solution if the inputs are the same?!?! How can that be? For example, in this predicate where I check for a body form:</div><div><br class=""></div><div><font face="Courier New" style="font-size: 15px;" class="">:- pred parse_body_term(snode::out, astcon::in, astcon::out) is multi.<br class=""><br class="">parse_body_term(Term, !A) :-<br class="">    (<br class="">        parse_atom(Term, !A)<br class="">    ;<br class="">        parse_list(Term, !A)<br class="">    ;<br class="">        parse_map(Term, !A)<br class="">    ;<br class="">        parse_feltcall(Term, !A)<br class="">    ;<br class="">        parse_fncall(Term, !A)<br class="">    ;<br class="">        parse_sexp(Term, !A)<br class="">    ).</font><br class=""><br class=""></div><div>I thought that this was semidet because either one of those disjuncts succeed or they all fail, I don’t understand why it says multi, multi is ‘can’t fail, >1 solutions’ but if I consume tokens in the parse_map() disjunct branch, how can it then come back for more? I just don’t get it, that’s something that really confuses me at the moment. Hence my question ‘what does it mean to have more than one solution?’. </div><div><br class=""></div><div>det: for example ‘*’, given x*y, the result is deterministic.</div><div>semidet: for example, given x/y, if y is nonzero the result is deterministic, if y is zero presumably it fails. pedagogical usage here that’s all.</div><div><br class=""></div><div>for me the confusion starts with `multi`, to have more than one solution surely it has to be called more than once with different inputs or is stepping through a set of facts?</div><div><br class=""></div><div>I think if I had managed to get mdb to work it might help to single step the code but I tried for a few hours and emacs version was wrong, lots of problems etc so I went back to ’thinking’ about it and trace[] all over the place.</div><div><br class=""></div><div>Not a good place to be at the moment but things worthwhile are never easy to attain.</div><div><br class=""></div><div>Thanks.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On 4 Jul 2021, at 16:56, Zoltan Somogyi <<a href="mailto:zoltan.somogyi@runbox.com" class="">zoltan.somogyi@runbox.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">2021-07-05 01:21 GMT+10:00 "Volker Wysk" <<a href="mailto:post@volker-wysk.de" class="">post@volker-wysk.de</a>>:<br class=""><blockquote type="cite" class="">I've built a big parser for my project, too. It should always produce one<br class="">solution; it can't fail. But the compiler can't infer that it is<br class="">deterministic, for many parts of it. (That would be undecidable.) <br class=""><br class="">So I've resigned to this state of affairs. I just collect all the (exactly<br class="">one) solutions with solutions/2 and produce an error message in case there<br class="">should be more than one, which would be a bug in my parser.<br class=""></blockquote><br class="">That works, but I would consider it fragile. The reason is that convincing<br class="">someone (the next maintainer of the parser, perhaps) that there will be<br class="">exactly one overall solution requires a single correctness argument over<br class="">the entire code, and humans are not very reliable as reasoning machines;<br class="">the longer the argument, the higher the probability of error.<br class=""><br class="">I would instead add disambiguation code to the places in the parser<br class="">than can introduce (as far as the compiler is concerned) the possibility<br class="">of nondeterminism. You can you can see why there is no such possibility;<br class="">I would try  to make the compiler that too. In most cases, this is not too hard,<br class="">at least in my experience.<br class=""><br class="">This approach replaces a single bug, global correctness argument with lots of<br class="">small, local correctness arguments, which can be understood, documented,<br class="">and if need be fixed, much more easily. Modularity in correctness arguments,<br class="">if you will.<br class=""><br class="">Zoltan.</div></div></blockquote></div><br class=""></div></body></html>