Overview
| Artifact ID: | 8884a53e30f751ec1733845abfbe991d4e02f1a720b24135f0e362b81e272230 |
|---|---|
| Ticket: | b5bd08df8d61b4ea9bf0cc885f790b367c430a9f
The "int" type registration should be restored. |
| User & Date: | apnadkarni on 2022-11-18 07:05:59 |
Changes
- icomment:
I'd like to point out one real world impact of this change. There is one category of extensions that are going to break - those interfacing to other languages that are typed (meaning almost all). This includes twapi, tcom, rl_json and probably jacl though I have not checked the last. I'll describe the issue in terms of Windows COM. When invoking a COM method via automation (IDispatch), the arguments are constructed one of two ways 1. using the called component's type library, or 2. in the case where the component does not provide a type library, based on the data type at the call site. For example, in VB `foo(1)` and `foo("1")` will pass the argument as integer and string respectively. The issue with invoking methods on components in the second category from Tcl should be obvious as `[foo 1]` provides no information about the type of the argument. However, even components in the first category, that provide type libraries, suffer from the same issue for overloaded methods take simply describe the type of the argument as `VARIANT` and then take different actions based on whether the argument is provided as an integer or (for example) string. Excel has several such methods. The "correct" way to deal with these cases in Tcl is to supply arguments as typed values, e.g. `foo [list int $val]` or `foo [list string $val]`. However, this is not only inconvenient for interactive use, it makes it difficult for applications and libraries that now have to deal with the same value represented in native Tcl form and a typed version. This is particularly painful in nested structures. So extensions have made use `Tcl_GetObjType` to guess the type and offer a "casting" mechanism that only needs to be used in special cases. This has worked surprisingly well in practice. A grep on my source base shows nsf, xotcl, jblend, twapi, tcom, rl_json and tcllib using `Tcl_GetObjType`. That does not mean they all break with this change, I've only verified that twapi, tcom and rl_json are affected. Note this means layered packages like CAWT (on twapi) or pandoc, tcljupyter (for rl_json) are also *potentially* impacted. I understand that perhaps `Tcl_GetObjType` was not intended to be used in this fashion (which then also raises the question of why it was there in the first place) but there was no other alternative without resorting to passing "type/value" pairs everywhere. /Ashok - login: "apnadkarni"
- mimetype: "text/x-markdown"