Author: Jos Decoster <firstname.lastname@example.org> State: Final Type: Project Vote: Done Created: 13-Dec-2011 Post-History: Discussions-To: news:comp.lang.tcl Keywords: Tcl Tcl-Version: 8.6 Obsoletes: 347 Implementation-URL: http://sites.google.com/site/josdecoster/Home/tip_string_is_entier.diff
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.
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.
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.
No incompatibilities are introduced.
The bignum was rejected in favor of entier because entier is already used in ::tcl::mathfunc::entier.
A reference implementation is available here: http://sites.google.com/site/josdecoster/Home/tip\_string\_is\_entier.diff
This document has been placed in the public domain.