TIP 544: Export TclGetIntForIndex()

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Author:         Jan Nijtmans <jan.nijtmans@users.sf.net>
Author:         François Vogel <fvogelnew1@free.fr>
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:

  • int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr)

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

  • int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, size_t endValue, size_t *indexPtr)

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.

Reference Implementation

Available on branch tip-544.

Copyright

This document has been placed in the public domain.

History