{"id":7257,"date":"2022-12-20T19:36:01","date_gmt":"2022-12-20T22:36:01","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/nre-man3-4\/"},"modified":"2022-12-20T19:36:01","modified_gmt":"2022-12-20T22:36:01","slug":"nre-man3-4","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/nre-man3-4\/","title":{"rendered":"NRE (man3)"},"content":{"rendered":"<h1 align=\"center\">NRE<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#ARGUMENTS\">ARGUMENTS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLE\">EXAMPLE<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#KEYWORDS\">KEYWORDS<\/a><br \/> <a href=\"#COPYRIGHT\">COPYRIGHT<\/a> <\/p>\n<hr>\n<p>______________________________________________________________________________<\/p>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_NRCreateCommand, Tcl_NRCallObjProc, Tcl_NREvalObj, Tcl_NREvalObjv, Tcl_NRCmdSwap, Tcl_NRExprObj, Tcl_NRAddCallback \u2212 Non-Recursive (stackless) evaluation of Tcl scripts.<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>#include <tcl.h><\/b><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_Command <b><br \/> Tcl_NRCreateCommand<\/b>(<i>interp, cmdName, proc, nreProc, clientData, <br \/> deleteProc<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_NRCallObjProc<\/b>(<i>interp, nreProc, clientData, objc, objv<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_NREvalObj<\/b>(<i>interp, objPtr, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_NREvalObjv<\/b>(<i>interp, objc, objv, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_NRCmdSwap<\/b>(<i>interp, cmd, objc, objv, flags<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">int <b><br \/> Tcl_NRExprObj<\/b>(<i>interp, objPtr, resultPtr<\/i>)<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">void <b><br \/> Tcl_NRAddCallback<\/b>(<i>interp, postProcPtr, data0, data1, data2, data3<\/i>)<\/p>\n<h2>ARGUMENTS <a name=\"ARGUMENTS\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p style=\"margin-top: 1em\">Tcl_Interp <i>*interp<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p style=\"margin-top: 1em\">The relevant Interpreter.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>char <i>*cmdName<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Name of the command to create.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_ObjCmdProc <i>*proc<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Called in order to evaluate a command. Is often just a small wrapper that uses <b>Tcl_NRCallObjProc<\/b> to call <i>nreProc<\/i> using a new trampoline. Behaves in the same way as the <i>proc<\/i> argument to <b>Tcl_CreateObjCommand<\/b>(3) (<i>q.v.<\/i>).<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_ObjCmdProc <i>*nreProc<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Called instead of <i>proc<\/i> when a trampoline is already in use.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>ClientData <i>clientData<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Arbitrary one-word value passed to <i>proc<\/i>, <i>nreProc<\/i>, <i>deleteProc<\/i> and <i>objProc<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_CmdDeleteProc <i>*deleteProc<\/i> (in\/out)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Called before <i>cmdName<\/i> is deleted from the interpreter, allowing for command-specific cleanup. May be NULL.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>int <i>objc<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Number of items in <i>objv<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_Obj <i>**objv<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Words in the command.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_Obj <i>*objPtr<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>A script or expression to evaluate.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>int <i>flags<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>As described for <i>Tcl_EvalObjv<\/i>.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_Command <i>cmd<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Token to use instead of one derived from the first word of <i>objv<\/i> in order to evaluate a command.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_Obj <i>*resultPtr<\/i> (out)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>Pointer to an unshared Tcl_Obj where the result of the evaluation is stored if the return code is TCL_OK.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>Tcl_NRPostProc <i>*postProcPtr<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p>A function to push.<\/p>\n<\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>ClientData <i>data0<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>ClientData <i>data1<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>ClientData <i>data2<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\"> <\/td>\n<\/tr>\n<tr valign=\"top\" align=\"left\">\n<td width=\"11%\"><\/td>\n<td width=\"58%\">\n<p>ClientData <i>data3<\/i> (in)<\/p>\n<\/td>\n<td width=\"3%\"><\/td>\n<td width=\"28%\">\n<p><i>data0<\/i> through <i>data3<\/i> are four one-word values that will be passed to the function designated by <i>postProcPtr<\/i> when it is invoked.<\/p>\n<\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:72%;\">______________________________________________________________________________<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">These functions provide an interface to the function stack that an interpreter iterates through to evaluate commands. The routine behind a command is implemented by an initial function and any additional functions that the routine pushes onto the stack as it progresses. The interpreter itself pushes functions onto the stack to react to the end of a routine and to exercise other forms of control such as switching between in-progress stacks and the evaluation of other scripts at additional levels without adding frames to the C stack. To execute a routine, the initial function for the routine is called and then a small bit of code called a <i>trampoline<\/i> iteratively takes functions off the stack and calls them, using the value of the last call as the value of the routine.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NRCallObjProc<\/b> calls <i>nreProc<\/i> using a new trampoline.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NRCreateCommand<\/b>, an alternative to <b>Tcl_CreateObjCommand<\/b>, resolves <i>cmdName<\/i>, which may contain namespace qualifiers, relative to the current namespace, creates a command by that name, and returns a token for the command which may be used in subsequent calls to <b>Tcl_GetCommandName<\/b>. Except for a few cases noted below any existing command by the same name is first deleted. If <i>interp<\/i> is in the process of being deleted <b>Tcl_NRCreateCommand<\/b> does not create any command, does not delete any command, and returns NULL.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NREvalObj<\/b> pushes a function that is like <b>Tcl_EvalObjEx<\/b> but consumes no space on the C stack.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NREvalObjv<\/b> pushes a function that is like <b>Tcl_EvalObjv<\/b> but consumes no space on the C stack.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NRCmdSwap<\/b> is like <b>Tcl_NREvalObjv<\/b>, but uses <i>cmd<\/i>, a token previously returned by <b>Tcl_CreateObjCommand<\/b> or <b>Tcl_GetCommandFromObj<\/b>, instead of resolving the first word of <i>objv<\/i>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NRExprObj<\/b> pushes a function that evaluates <i>objPtr<\/i> as an expression in the same manner as <b>Tcl_ExprObj<\/b> but without consuming space on the C stack.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">All of the functions return <b>TCL_OK<\/b> if the evaluation of the script, command, or expression has been scheduled successfully. Otherwise (for example if the command name cannot be resolved), they return <b>TCL_ERROR<\/b> and store a message as the interpreter\u2019s result.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>Tcl_NRAddCallback<\/b> pushes <i>postProcPtr<\/i>. The signature for <b>Tcl_NRPostProc<\/b> is:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">typedef int <b><br \/> Tcl_NRPostProc<\/b>( <b><br \/> ClientData<\/b> <i>data<\/i>[], <b><br \/> Tcl_Interp<\/b> *<i>interp<\/i>, <br \/> int <i>result<\/i>);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><i>data<\/i> is a pointer to an array containing <i>data0<\/i> through <i>data3<\/i>. <i>result<\/i> is the value returned by the previous function implementing part the routine.<\/p>\n<h2>EXAMPLE <a name=\"EXAMPLE\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The following command uses <b>Tcl_EvalObjEx<\/b>, which consumes space on the C stack, to evalute a script:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">int <i><br \/> TheCmdOldObjProc<\/i>( <br \/> ClientData clientData, <br \/> Tcl_Interp *interp, <br \/> int objc, <br \/> Tcl_Obj *const objv[]) <br \/> { <br \/> int result; <br \/> Tcl_Obj *objPtr;<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>&#8230; preparation &#8230;<\/i><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">result = <b>Tcl_EvalObjEx<\/b>(interp, objPtr, 0);<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>&#8230; postprocessing &#8230;<\/i><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">return result; <br \/> } <b><br \/> Tcl_CreateObjCommand<\/b>(interp, &#8220;theCommand&#8221;, <i><br \/> TheCmdOldObjProc<\/i>, clientData, TheCmdDeleteProc);<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">To avoid consuming space on the C stack, <i>TheCmdOldObjProc<\/i> is renamed to <i>TheCmdNRObjProc<\/i> and the postprocessing step is split into a separate function, <i>TheCmdPostProc<\/i>, which is pushed onto the function stack. <i>Tcl_EvalObjEx<\/i> is replaced with <i>Tcl_NREvalObj<\/i>, which uses a trampoline instead of consuming space on the C stack. A new version of <i>TheCmdOldObjProc<\/i> is just a a wrapper that uses <b>Tcl_NRCallObjProc<\/b> to call <i>TheCmdNRObjProc<\/i>:<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">int <i><br \/> TheCmdOldObjProc<\/i>( <br \/> ClientData clientData, <br \/> Tcl_Interp *interp, <br \/> int objc, <br \/> Tcl_Obj *const objv[]) <br \/> { <br \/> return <b>Tcl_NRCallObjProc<\/b>(interp, <i>TheCmdNRObjProc<\/i>, <br \/> clientData, objc, objv); <br \/> }<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">int <i><br \/> TheCmdNRObjProc<\/i> <br \/> ClientData clientData, <br \/> Tcl_Interp *interp, <br \/> int objc, <br \/> Tcl_Obj *const objv[]) <br \/> { <br \/> Tcl_Obj *objPtr;<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>&#8230; preparation &#8230;<\/i><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><b>Tcl_NRAddCallback<\/b>(interp, <i>TheCmdPostProc<\/i>, <br \/> data0, data1, data2, data3); <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var <i>data0 .. data3<\/i> are up to four one-word items to <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr pass to the postprocessing procedure *\/<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">return <b>Tcl_NREvalObj<\/b>(interp, objPtr, 0); <br \/> }<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">int <i><br \/> TheCmdNRPostProc<\/i>( <br \/> ClientData data[], <br \/> Tcl_Interp *interp, <br \/> int result) <br \/> { <br \/> \/bin \/boot \/dead.letter \/dev \/etc \/home \/initrd \/lib \/lib64 \/lost+found \/media \/mnt \/opt \/proc \/release-notes.html \/release-notes.txt \/root \/run \/sbin \/srv \/sys \/tmp \/usr \/var <i>data[0] .. data[3]<\/i> are the four words of data <br \/> bodies manpages.csv script_extrae_body.sh script.sh usr passed to <b>Tcl_NRAddCallback<\/b> *\/<\/p>\n<p style=\"margin-left:22%; margin-top: 1em\"><i>&#8230; postprocessing &#8230;<\/i><\/p>\n<p style=\"margin-left:22%; margin-top: 1em\">return result; <br \/> }<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Any function comprising a routine can push other functions, making it possible implement looping and sequencing constructs using the function stack.<\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Tcl_CreateCommand(3), Tcl_CreateObjCommand(3), Tcl_EvalObjEx(3), Tcl_GetCommandFromObj(3), Tcl_ExprObj(3)<\/p>\n<h2>KEYWORDS <a name=\"KEYWORDS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">stackless, nonrecursive, execute, command, global, value, result, script<\/p>\n<h2>COPYRIGHT <a name=\"COPYRIGHT\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">Copyright (c) 2008 by Kevin B. Kenny. Copyright (c) 2018 by Nathan Coulter.<\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  Tcl_NRCreateCommand, Tcl_NRCallObjProc, Tcl_NREvalObj, Tcl_NREvalObjv, Tcl_NRCmdSwap, Tcl_NRExprObj, Tcl_NRAddCallback \u2212 Non-Recursive (stackless) evaluation of Tcl scripts. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2536],"tags":[2538,3007,3582],"class_list":["post-7257","post","type-post","status-publish","format-standard","hentry","category-3-llamadas-de-bibliotecas","tag-2538","tag-man3","tag-tcl_nraddcallback"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7257","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=7257"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/7257\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=7257"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=7257"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=7257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}