Artifact 8a3b8846166a2e92e6109fa816cbe805f01b942410ecd7ca2603e66a893ae572:
- File tip/544.md — part of check-in [7f746896f3] at 2023-04-18 06:08:42 on branch tip-660 — Investigate which TIP's are affected by TIP #660 (user: jan.nijtmans size: 1663) [more...]
TIP 544: Export TclGetIntForIndex()
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:
- int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr)
For Tcl 9.0, all indexes have type Tcl_Size
, so there the signature is:
- int Tcl_GetIntForIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, Tcl_Size endValue, Tcl_Size *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.
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.