TIP #395: NEW 'STRING IS ENTIER' COMMAND ========================================== Version: $Revision: 1.5 $ Author: Jos Decoster State: Final Type: Project Tcl-Version: 8.6 Vote: Done Created: Tuesday, 13 December 2011 URL: https://tip.tcl-lang.org395.html Discussions-To: news:comp.lang.tcl Post-History: Obsoletes: TIP #347 ------------------------------------------------------------------------- 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: COPYRIGHT =========== This document has been placed in the public domain. ------------------------------------------------------------------------- TIP AutoGenerator - written by Donal K. Fellows