On 11/05/2012 11:56, Michael Talbot-Wilson wrote:
> On 2012-05-11, Michael Talbot-Wilson<mtw@view> wrote:
>> Message returned by catch to a 'source /usr/local/lib/tcl8.6/init.tcl'.
>
> I should have said that I've had to do a wholesale replacement of
> "interp->result" with Tcl_GetStringResult(interp).
That's not right either. The work-around fix is to define the macro
USE_INTERP_RESULT when compiling, which re-exposes the field. Be aware
that we are going to get rid of the field entirely in the not very
distant future; it's _truly_ deprecated (and if you're building with the
development trunk with gcc, you'll get warnings even that macro defined).
> - sprintf (interp->result, "%d %d", rx, ry);
> + sprintf (Tcl_GetStringResult(interp), "%d %d", rx, ry);
The best way to write that now is:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%d %d", rx, ry));
In many ways, that actually says what is happening better than the other
two. OTOH, it might also be worthwhile actually building a list of two
numbers there; more code, but faster (both to generate and to parse).
Tcl_Obj *objs[2];
objs[0] = Tcl_NewIntObj(rx);
objs[1] = Tcl_NewIntObj(ry);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, objs));
Perhaps there ought to be a varargs version of that... (There isn't
right now.)
> - interp->result = Tk_PathName(RasterPtr->tkwin);
> + Tcl_SetResult(interp, Tk_PathName(RasterPtr->tkwin), TCL_DYNAMIC);
>
> (where TCL_DYNAMIC is a pure guess).
Tcl_SetResult is still a supported interface (if not especially fast)
but the right values there are TCL_STATIC or TCL_VOLATILE as you don't
want Tcl to deallocate that string immediately.
Donal.