From: Donal K. F. <don...@ma...> - 2008-12-04 12:26:25
|
Twylite wrote: >> Side question: if you're working in C code there is no "catch context" >> -- you just get a non-zero return value. I had imagined the bytecode >> would be similar? >> > Never mind. But there need to be bigger health warnings on > tclExecute.c and tclCompile.c. I don't think they make letters that large except in books by Douglas Adams... > Of course this is easier said than done. Everything calls down to "void > Tcl_SetObjErrorCode(Tcl_Interp *interp, Tcl_Obj *errorObjPtr)" which > makes for one convenient place to fix the problem, but the function is > published in the stubs table and returns (void) ... which makes it > tricky to fix. While I know how to fix such things through stub-table rearrangement (and I've done such in parts of Tk) they're pretty ugly to do. What we *can* do is make sure that Tcl code doesn't mess this up through [error], [return] (and [throw]). I don't think anyone is actually generating bad error codes anyway; at the C level, the convenient API produces proper lists. > One could fix TclProcessReturn() to check valuePtr just before calling > Tcl_SetObjErrorCode (context below) ... [...] > ... which would at least make this safe at a script level, so that only > C code calling Tcl_SetObjErrorCode directly can mess things up. Things are fairly messy in this area. Donal. |