<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;"><div style="">Thank you Julien,</div><div style=""><br></div><div style="">I have solved my problem, not sure if I *totally* understand what with me being a bit slow and all that but here goes....</div><div style=""><br></div><div style="">Firstly, I found a small bug, in my tail-call in the predicate merth_session_() I was calling back to the parent predicate, merth_session/4, without the underscore on the end, the 'aux' predicate I guess, from Prolog hackery days. I actually removed that call as it, with the try catch etc the control flow requirements changed a little, the bug was found by the compiler because I had had to change the merth_session/4 to cc_multi and so calling back to the cc_multi predicate from the det aux. p[redicate raised the error.</div><div style=""><br></div><div style="">Then, in my main/2 predicate I now have this:</div><div style=""><br></div><div style=""><div><font face="Edlo"> S0 = merth_init_with(tokens(L)),</font></div><div><font face="Edlo"> S1 = S0 ^merth_mode := interp_mode,</font></div><div><span style="font-family: Edlo;"> promise_equivalent_solutions [!:IO] </span><span style="font-family: Edlo;">merth_session(S1, _, !IO).</span></div></div><div style=""><br></div><div style=""><br></div><div style="">Currently I don't care about the final state of the session, although this particular project is going to form a part of my transpiler, it's a stack based FORTH type dialect I've been pondering on for quite a while, hence the name MERTH, or <b>ME</b>rcury fo<b>RTH</b>. It makes me laugh, too. It currently has these words and grows daily, I am currently working on control flow stack stiff for IF THEN ELSE</div><div style=""><br></div><div style=""><font face="Edlo">* + - -ROT . .S / 0< 0<= 0<> 0= 0> 0>= : ; < <= <> = > >= ?DUP BYE CR DROP DUP EMIT FALSE NIP OVER ROT SEE SPACE SPACES SWAP TRACE TRUE TUCK T{ VMTRACE WORDS }T</font></div><div style=""><br></div><div style="">I digress!</div><div style=""><br></div><div style="">Then I had to change the declaration of merth_session/4 to be this:</div><div style=""><br></div><div style=""><div><font face="Edlo">:- pred merth_session(mstate::in, mstate::out, io::di, io::uo) is cc_multi.</font></div><div><span style="font-family: Edlo;"><br></span></div><div><span style="font-family: Edlo;">merth_session(!S, !IO) :-</span></div><div><font face="Edlo"> (</font></div><div><font face="Edlo"> try [ io(!IO) ]</font></div><div><font face="Edlo"> merth_session_(!S, !IO)</font></div><div><font face="Edlo"> then</font></div><div><font face="Edlo"> !S ^loop_count := loop_count(!.S)+1,</font></div><div><font face="Edlo"> ( if !.S ^exit = no then</font></div><div><font face="Edlo"> merth_session(!S, !IO)</font></div><div><font face="Edlo"> else</font></div><div><font face="Edlo"> true</font></div><div><font face="Edlo"> )</font></div><div><font face="Edlo"><br></font></div><div><font face="Edlo"> catch stack_depth(X, Y) -></font></div><div><font face="Edlo"> console_error("Stack depth! %i %i", [ i(X), i(Y)], !IO)</font></div><div><font face="Edlo"><br></font></div><div><font face="Edlo"> catch stack_type_int(T) -></font></div><div><font face="Edlo"> console_error("Wrong type, int expected, got %s",</font></div><div><font face="Edlo"> [ s(string(T)) ], !IO)</font></div><div><font face="Edlo"><br></font></div><div><font face="Edlo"> catch compile_time_word(Word) -></font></div><div><font face="Edlo"> console_error("%s is compile time only", [ s(Word) ], !IO)</font></div><div><font face="Edlo"><br></font></div><div><font face="Edlo"> catch interpret_time_word(Word) -></font></div><div><font face="Edlo"> console_error("%s is interpret time only", [ s(Word) ], !IO)</font></div><div><font face="Edlo"> ).</font></div></div><div style=""><br></div><div style="">This is because, if I understand what Julien tells me, is because in the manual it says '<span style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">A try goal has determinism </span><code style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">cc_multi</code><span style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">.' which then means that the containing predicate also has to be declared as cc_multi, hence the need for the promise_equivalent_solutions in main.</span></div><div style=""><span style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><br></span></div><div style=""><span style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">And finally, the auxiliary predicate is a simple deterministic one:</span></div><div style=""><br></div><div><span style="font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; font-size: 19px;"><div style="font-size: 14px;"><div><font face="Edlo">:- pred merth_session_(mstate::in, mstate::out, io::di, io::uo) is det.</font></div><div><font face="Edlo"><br></font></div><div><font face="Edlo">merth_session_(!S, !IO) :-</font></div></div><div style="font-size: 14px;"><font face="Edlo"> :</font></div><div style="font-size: 14px;"><font face="Edlo"> :</font></div><div style="font-size: 14px;"><br></div><div style="font-size: 14px;">So, I figured it out, I *think* I understand why I did what I did, but as usual if anybody has the time and energy to expand / add further details I am always very happy to read such details!</div><div style="font-size: 14px;"><br></div><div style="font-size: 14px;">Thanks Julien.</div><div style="font-size: 14px;"><br></div><div style="font-size: 14px;">:)</div><div style="font-size: 14px;">Sean</div><div style="font-size: 14px;"><br></div><div style="font-size: 14px;">PS. Have I ever said I love Mercury even though it confounds me at times?</div><div><br></div></span></div></body></html>