<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">I have these defined as exceptions that can be thrown in my code:<div><br></div><div><div>:- type stack_error</div><div> ---> stack_depth(int, int) % need N values, only had M.</div><div> ; stack_type_int(string) % wanted int, got a U</div><div> ; compile_time_word(string) % can't be used in interp mode.</div><div> ; interpret_time_word(string) % expected to be interpreting.</div><div> .</div></div><div><br></div><div>In my main execution code, I have predicate that I want to loop, catch any exceptions and then just rinse-repeat until the user ends the session:</div><div><br></div><div><div> 171 :- pred merth_session(mstate::in, mstate::out, io::di, io::uo) is det.</div><div> 172 </div><div> 173 merth_session(!S, !IO) :-</div><div> 174 try [ io(!IO) ]</div><div> 175 % promise_equivalent_solutions [!S, !IO]</div><div> 176 merth_session_(!S, !IO)</div><div> 177 then</div><div> 178 merth_session(!S, !IO)</div><div> 179 </div><div> 180 catch stack_depth(X, Y) -></div><div> 181 console_error("Stack depth! %i %i", [ i(X), i(Y)], !IO)</div><div> 182 </div><div> 183 catch stack_type_int(T) -></div><div> 184 console_error("Wrong type, int expected, got %s",</div><div> 185 [ s(string(T)) ], !IO)</div><div> 186 </div><div> 187 catch compile_time_word(Word) -></div><div> 188 console_error("%s is compile time only", [ s(Word) ], !IO)</div><div> 189 </div><div> 190 catch interpret_time_word(Word) -></div><div> 191 console_error("%s is interpret time only", [ s(Word) ], !IO).</div></div><div><br></div><div>The compiler error is:</div><div><br></div><div><div>merth.m:171: In `merth_session'(in, out, di, uo):</div><div>merth.m:171: error: determinism declaration not satisfied.</div><div>merth.m:171: Declared `det', inferred `multi'.</div><div>merth.m:171: The reason for the difference is the following.</div><div>merth.m:174: Call to</div><div>merth.m:174: `exception.magic_exception_result'(out((exception.cannot_fail)))</div><div>merth.m:174: can succeed more than once.</div><div>merth.m:174: Error: call to predicate `exception.magic_exception_result'/1 with</div><div>merth.m:174: determinism `cc_multi' occurs in a context which requires all</div><div>merth.m:174: solutions.</div></div><div><br></div><div><br></div><div>In the user manual, seciton 14, Exception handling, at the top it says:</div><div><br></div><div><i><span class="Apple-tab-span" style="white-space:pre"> </span>Goal must have one of the following determinisms: det, semidet, cc_multi, or cc_nondet.</i></div><div><br></div><div>And then further down it says:</div><div><br></div><div style="orphans: 2; widows: 2;"><i><span class="Apple-tab-span" style="white-space: pre;"> </span>A try goal has determinism cc_multi.</i></div><div style="orphans: 2; widows: 2;"><i><br></i></div><div style="orphans: 2; widows: 2;">I am just a little confused at this point as to what I am being told by the compiler, I can't even see 'magic_exception' so it's inferred something perhaps? Do I need a catch_any, that's optional though?</div><div style="orphans: 2; widows: 2;"><br></div><div style="orphans: 2; widows: 2;">Thanks.</div><div style="orphans: 2; widows: 2;"><br></div><div><br></div></body></html>