Overview
| Artifact ID: | 7aa979cac5d41d319b2c7a2276269166a2abb4be |
|---|---|
| Ticket: | 1917650fffffffffffffffffffffffffffffffff
Tcl_ConvertToType(, , doubleType) incompatibility |
| User & Date: | ferrieux on 2008-06-17 04:26:55 |
Changes
- icomment:
Logged In: YES user_id=496139 Originator: NO > An object-type's setFromAnyProc is not something that is meant to be > directly called by external code. That's peculiar ! Why would the function be stored in a vector (Tcl_ObjType), if it were not to be called polymorphically ? The natural tool for this polymorphic call is Tcl_ConverToType, which is in the main stubs. Hard to get more public... Now there's the contract. The documentation says that an attempt at conversion is made, but also says that the TCL_OK/TCL_ERROR result can be used as a boolean test of success. So it quite clearly means that result==TCL_OK => final type == requested type Now, it turns out that this contract is respected for all non-numeric types, and violated for all numeric types ! Worse, if we concentrate on those numeric types (in tclObj.c) and try to identify the relationships between the setFromAnyProc and the Tcl_SetXXXFromObj procs, we can see a total mess: TYPETcl_GetXXXFromObjSetXXXFromAny intnot always shimmer(+parse_integer)convergent widenot always shimmer(+parse_integer)<- bignumnot always shimmer(+parse_integer)none doublenot always shimmer (+parse any)-> booleannot always shimmer (+parse any)convergent In this table, the third column means: convergent: both procs call a third one. none: the setupProc is NULL -> T_GXFO calls the SFAproc <- the SFAproc calls T_GXFO The second column warns that the T_GXFO take care to avoid shimmering when possible The (+parse...) tels which flags are passed to TclParseNumber. Again, this is messy. But what about cleaning that up a bit ? My proposal would be to keep the non-shimmering feature of T_GXFO (since they all have an output parameter distinct from the obj), while enforcing the type contract for the SFAproc, when non-NULL (bignums have a null SFAproc, just like Cons). Also, why Tcl_Panic in Tcl_ConvertToType for types with a null SFAproc ? Why not simply return TCL_ERROR ? Reactions ? -Alex
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"