TIP 544: Export TclGetIntForIndex()

Login
Author:         Jan Nijtmans <[email protected]>
Author:         François Vogel <[email protected]>
State:          Final
Type:           Project
Tcl-Version:    8.7
Vote:           Done
Created:        15-May-2019
Post-History:
Discussions-To: Tcl Core list
Keywords:       Tcl
Tcl-Version:    8.7
Tcl-Branch:     tip-544

Abstract

This TIP proposes to export the internal function TclGetIntForIndex() as Tcl_GetIntForIndex(). The signature is:

For Tcl 9.0, all indexes have type Tcl_Size, so there the signature is:

Rationale

This function can be used for extensions to parse indexes like "end-5", "12+1" ... See TIP 502: Index Value Reform and TIP 176: Add String index Values.

Use case in Tk: see Tcl-core list discussion of TIP 541: Add support for 'end' index in ttk::combobox current.

Compatibility

This is fully upwards compatible with Tcl 8.6.

Addendum

After TIP #660 was accepted, a lot of functions changed from using size_t to ptrdiff_t parameters. In order to prevent confusion, this change has been adapted in the TIP text above as well.

Reference Implementation

Available on branch tip-544.

Copyright

This document has been placed in the public domain.