TIP #395: New 'string is entier' Command
_____________________________________________________________________________
TIP:	395
Title:	New 'string is entier' Command
Version:	$Revision: 1.5 $
Authors:	Jos Decoster <jos.decoster@gmail.com>
State:	Final
Type:	Project
Tcl-Version:	8.6
Vote:	Done
Created:	Tue Dec 13 00:00:00 UTC 2011
Keywords:	Tcl
Abstract
The string is command supports tests for a number of Tcl's basic types, for example, integers, doubles, and booleans. One common case is missing: checking if a value is an integer number without particular storage width, unlike string is integer and string is wideinteger. This document proposes to augment the string is command with a string is entier.
Rationale
Tcl makes it easy to work with integers larger than 64 bit (big nums). The expr command supports operations on unlimited bit widths. Checking if a string contains a valid integer value is possible with the string is integer and string is wideinteger commands for integers of particular storage widths (e.g. 32 bit for integers and 64 bit for wide integers). But checking if a string contains a valid integer wider than a wideinteger is not possible with a string is command. Checking if a string contains a valid big num can now be done with a regular expression or by catch-ing the ::tcl::mathfunc::entier function.
Specification
This document proposes to augment the string is command with a string is entier which functions the same as string is integer in every respect except for the fact that it accepts any string containing a substring that is valid as a bignum integer (that is, acceptable to Tcl_GetBignumFromObj) possibly surrounded by whitespace.
Compatibility
No incompatibilities are introduced.
Alternatives
The bignum was rejected in favor of entier because entier is already used in ::tcl::mathfunc::entier.
Reference Implementation
A reference implementation is available here:
 http://sites.google.com/site/josdecoster/Home/tip_string_is_entier.diff
Copyright
This document has been placed in the public domain.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows