<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="">Hi,<div class=""><br class=""></div><div class="">I am trying to pass around a predicate to execute at a later point in my translation process:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 14px;" class="">:- type renderer == (pred(instruction, lstring, rop_error, tcon, tcon)).<br class="">:- inst renderer == (pred(in, in, out, in, out) is det).</font><br class=""><br class=""></div><div class="">then to set the renderer:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 14px;" class=""> Renderer = target_c.render</font><br class=""><br class=""></div><div class="">then I have a work in progress evaluation predicate:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 14px;" class="">:- pred eval(renderer::in, location::in, instruction::in, lsnode::in,<br class=""> renderout::out, tcon::in, tcon::out) is semidet.</font><br class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 14px;" class="">eval(Render, Pos, defvar, Args, Result, !T) :-<br class=""> trace[io(!Dbg), runtime(env("FELT_TRN"))]<br class=""> (sdump($pred, $line, Args, !Dbg)),<br class=""><br class=""> ( if Args = [tk(Pos, VarName)] then<br class=""> %<br class=""> % this it not working well<br class=""> % ...what can be done to make it better ?<br class=""> %<br class=""><b class="">348</b> Render(defvar, lstring(Pos, VarName), CodeM, !T),<br class=""> absorb(CodeM, Result, !T)<br class=""><br class=""> else if Args = [ tk(VPos, VarName), _RHS ] then<br class=""> Render(defvar, lstring(VPos, VarName), CodeM, !T),<br class=""> absorb(CodeM, Result, !T)<br class=""><br class=""> else<br class=""> add_error(Pos, defvar_form_error, !T),<br class=""><b class="">357</b> Result = no<br class=""> ).</font></div><div class=""><br class=""></div><div class="">And I get the error:</div><div class=""><br class=""></div><div class="">translate.m:357: In clause for `eval(in, in, in, in, out, in, out)':<br class="">translate.m:357: mode error in conjunction. The next 3 error messages<br class="">translate.m:357: indicate possible causes of this error.<br class="">translate.m:357: <br class="">translate.m:349: In clause for `eval(in, in, in, in, out, in, out)':<br class="">translate.m:349: mode error in conjunction. The next 2 error messages<br class="">translate.m:349: indicate possible causes of this error.<br class="">translate.m:349: <br class="">translate.m:348: In clause for `eval(in, in, in, in, out, in, out)':<br class="">translate.m:348: in argument 1 (i.e. the predicate term) of higher-order<br class="">translate.m:348: predicate call:<br class="">translate.m:348: mode error: variable `Render' has instantiatedness `ground',<br class="">translate.m:348: expecting higher-order pred inst of arity 5.<br class="">translate.m:349: <br class="">translate.m:349: In clause for `eval(in, in, in, in, out, in, out)':<br class="">... error log truncated, see `translate.err' for the complete log.</div><div class=""><br class=""></div><div class="">and I fail to understand. It’s passed down from the top level code, I wrote a little test predicate to isolate the error:</div><div class=""><br class=""></div><div class="">:- pred testcall(renderer::in, tcon::in, tcon::out, io::di, io::uo) is det.<br class="">testcall(R,!T,!IO) :-<br class=""> (if R(include, lstring(pos(0,0,0),"testing"), Result, !T)<br class=""> then<br class=""> io.format("TESTED OUTPUT: %s", [s(string(Result))], !IO)<br class=""> else true).</div><div class=""><br class=""></div><div class="">This fails to compile but calling the Render within its defining scope works</div><div class=""><br class=""></div><div class=""> Renderer(include, lstring(pos(0,0,0), “test”), Result, !T) …</div><div class=""><br class=""></div><div class="">happily calls out to the relevant translation function. What’s the problem in handing it down as a parameter please ?</div><div class=""><br class=""></div><div class="">Thanks</div><div class="">Sean</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>