Skip to content
Tcl Source Code Artifact [a9ef0e7e3e]
Login

Artifact [a9ef0e7e3e]

Artifact a9ef0e7e3e67d709bd7879e09b16513178b84808037427eb83219dd8b1da7cab:

Wiki page [Migrating C extensions to Tcl 9] by griffin on 2023-10-30 21:34:51.
D 2023-10-30T21:34:51.885
L Migrating\sC\sextensions\sto\sTcl\s9
N text/x-markdown
P 478d2e716785ad3d63e13a856b4f93e8fb632cf52faadf876a654a89a29a2a3b
U griffin
W 1990
(Work in progress...)

## 64-bit support

`Tcl_Size` etc.

TBD

## Unicode support

32-bit Tcl_UniChar, profiles...

TBD

## `Tcl_ObjType` versioning

The Tcl value system has been extended. The Tcl\_ObjType has additional (optional) fields.  Any Tcl extensions, or embedded integration with Tcl, that has a custom Tcl\_ObjType value defined, should review these changes.  Existing code should compile and execute just fine, unless the particular implementation is using any "creative" programming. In simpler terms, the Tcl\_ObjType structure is larger. It should be initialzed properly without any changes needed, but YMMV.

Please see the Tcl_RegisterObjType manual page for more details, as well as TIPs #644 and #636.

## Abstract lists

An abstract list is a custom Tcl Value (custom Tcl_ObjType) that can be treated as a Tcl List at the script level without causing the value to be converted to a List type. To make this possible, the custom type must implment a set of accessor functions that allow the various list commands to access the value "elements" directly. 

See the Tcl_RegisterObjType manual page for more details, as well as TIPs #644 and #636.

## Tcl Lists

### 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. 


Z d555eec23f3380caf2d7a12956827a6d