|Title:||New 'string is entier' Command|
|Version:||$Revision: 1.5 $|
|Author:||Jos Decoster <jos dot decoster at gmail dot com>|
|Created:||Tuesday, 13 December 2011|
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:
This document has been placed in the public domain.
[Index] [History] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]TIP AutoGenerator - written by Donal K. Fellows