TIP 546: Typedefs to Support Source-Compatible Migration

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Author:         Don Porter <dgp@users.sourceforge.net>
State:          Draft
Type:           Project
Tcl-Version:    8.7
Vote:           Pending
Created:        20-May-2019
Keywords:       Tcl, traces
Post-History:

Abstract

This TIP proposes new typedefs for the public interfaces of Tcl 8.7 and Tcl 9.0 to permit single-source-code extensions to be compiled and loaded in the ecosystem of each major Tcl release.

Background

Implicit constraints of many public Tcl routines have come to annoy programmers more and more as the years go by. Notably size limits prevent Tcl programs making full use of the resources of platforms that are utterly conventional today. Many TIPs for Tcl 9 directly call for new, binary-incompatible routines to overcome these limits. (Add references here).

The careful definition of typedefs can parameterize many of the changes needed, and in the process create tools for writing extensions with source code that bridges compatibility with both the Tcl 8 and Tcl 9 releases, and which can also assist with portability testing of the suitability of Tcl 9 on 32-bit platforms, even as fewer and fewer developers have routine access to them.

This TIP is in the Draft State, but it truly is in Draft form. Comments and contributions are actively encouraged.

Rationale

The following set of typedefs are useful for Tcl interface migration support:

Tcl_Size

Many arguments to public Tcl routines characterize the size of some other argument in terms of a count of smaller components it contains. Any argument like this needs to have a type that meets several criteria.

  • It should be an integral type of the C language, so that basic operations of comparison and arithmetic are available in expected ways.

  • The value 0 must be included in the type Tcl_Size so that empty containers can be described.

  • A value TCL_SIZE_MAX must be defined, indicating the largest size value included in the Tcl_Size type.

  • All values between 0 and TCL_SIZE_MAX are also supported as meaningful sizes in the Tcl_Size type.

  • Another value TCL_SIZE_UNKNOWN, distinct from all those mentioned so far, is also included in the type Tcl_Size as a way to indicate lack of knowledge or specification of a size. This is analogous to the NULL value for pointers.

Tcl_Idx

Specification

Compatibility

Reference Implementation

Will be drafted in tip-546 branches.

Copyright

This document has been placed in the public domain.

History