145
146
147
148
149
150
151
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
+
+
+
+
+
+
+
+
+
+
+
|
### Tcl_Obj reference counting
It is often common practice when indexing a Tcl List, to not include Incr and Decr RefCounts on the element Tcl_Obj when the use is local and temporary. This was because the List already has a reference to the element, and the Incr/Decr sequence would have no material effect. A minor performance gain. With the introduction of Abstract Lists, it is possible for elements to be created on demand by the Index operation, so the new element Obj may have a refCount of 0. Therefore, existing code that skip RefCounting operations could be at risk of leaking memory. Such code should include appropriate Incr/Decr calls, or make use of the new Tcl_BounceRefCount() function. This new function will check for a zero refCount and free the Tcl_Obj.
## Tommath
Tcl 9 optionally allows the linking of an external `libtommath` library for multiple-precision
integer arithmetic in lieu of Tcl's internal version. This has some consequences for extensions:
* If including `tclTomMath.h`, Tcl's stubs interface to `libtommath` is used and only a subset of
`libtommath` functions are available. If including `tommath.h` (external library), all `libtommath`
functions are available.
* Extensions using the definitions of `mp_digit`, `mp_word` or `mp_int` need to include either
`tclTomMath.h` or `tommath.h` in addition `tcl.h`.
See See [TIP 538](https://core.tcl-lang.org/tips/doc/trunk/tip/538.md).
|