# TIP 544: Export TclGetIntForIndex()
	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 `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](502.md) and
[TIP 176: Add String index Values](176.md).

Use case  in Tk: see
[Tcl-core list discussion](http://code.activestate.com/lists/tcl-core/20663/)
of
[TIP 541: Add support for 'end' index in ttk::combobox current](541.md).

# Compatibility

This is fully upwards compatible with Tcl 8.6.

# Addendum

After [TIP #660](660.md) 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](https://core.tcl-lang.org/tcl/timeline?t=tip-544).

# Copyright

This document has been placed in the public domain.
