This is not necessarily the current version of this TIP.
| TIP: | 353 |
| Title: | NR-enabled Expressions for Extensions |
| Version: | $Revision: 1.6 $ |
| Author: | Don Porter <dgp at users dot sf dot net> |
| State: | Accepted |
| Type: | Project |
| Tcl-Version: | 8.6 |
| Vote: | Done |
| Created: | Wednesday, 29 July 2009 |
This TIP proposes the new public routine Tcl_NRExprObj to provide extension commands that evaluate Tcl expressions the ability to do so in a non-recursive manner.
In a few contexts, expressions that contain yield raise the error "cannot yield: C stack busy"; see Tcl Bugs 2823282 [1] and 2823276 [2]. This is because a few little-visited corners of Tcl's implementation call the routine Tcl_ExprObj and that routine is not NR-enabled.
For extensions wishing to evaluate Tcl expressions, Tcl_ExprObj is not little-visited. It is the public, supported, recommended tool for the job. Just as TIP #322 provided a routine Tcl_NREvalObj as an NR-enabled replacement for Tcl_EvalObj, extensions wishing to NR-enable their commands need an analogous replacement for Tcl_ExprObj.
Tcl has a long history of providing extensions access to the same capabilities available to the built-in command set so that extension commands are on an equal footing, not in a second class status. Keeping with that, we want extensions to be able to create NR-enabled commands, so we need to provide an interface for extensions to evaluate expressions in an NR-enabled manner. This TIP can be seen as filling up a hole in TIP #322.
The Tcl public C interface provides a whole family of variants of Tcl_ExprObj: Tcl_ExprLongObj, Tcl_ExprDoubleObj, Tcl_ExprBooleanObj, Tcl_ExprLong, Tcl_ExprDouble, Tcl_ExprBoolean, Tcl_ExprString. NR-enabled counterparts to these routines are not proposed. Extensions rewriting their command procedures to use the proposed Tcl_NRExprObj for sake of NR-enabling can at the same time be expected to convert from these convenience wrappers to more direct use of a single NR-enabled primitive.
Add the following routine to Tcl's public interface: