TIP #269: Add 'string is list' to the 'string is' Subcommand
_____________________________________________________________________________
TIP:	269
Title:	Add 'string is list' to the 'string is' Subcommand
Version:	$Revision: 1.7 $
Authors:	Joe Mistachkin <joe@mistachkin.com>
State:	Final
Type:	Project
Tcl-Version:	8.5
Vote:	Done
Created:	Fri May 19 00:00:00 UTC 2006
Keywords:	Tcl, lists, strings
Abstract
The string command supports tests for a number of Tcl's basic types, for example, integers, doubles, and booleans. This TIP proposes adding lists to the set of things that can be checked for.
Rationale
The string command includes tests for the common Tcl types: string is boolean, string is double and string is integer. Unaccountably, string is list is missing from the list, making it difficult for an input validation procedure to determine whether, in fact, a string contains a proper list.
Currently, something similar to the following incantation is required:
 set is_list [expr ![catch llength $str]]
The above construct (and others like it) are extremely counterintuitive, especially to people without intimate knowledge of Tcl.
Compare and contrast with:
 set is_list [string is list $str]
Since string is currently serves in this capacity for determining whether a string can be correctly interpreted as an integer or double, it seems only natural to extend it so that it can determine whether a string can be correctly interpreted as a list.
Specification
This document proposes augmenting the string is command with a string is list subcommand, as follows:
string is list ?-strict? ?-failindex var? str
The result will be 1 if the string has proper list structure; otherwise, it will be 0. The option -strict is accepted for syntactic compatability with other forms of string is but has no effect since empty strings are proper lists.
Reference Implementation
A reference implementation of this TIP is available [http://sf.net/tracker/?func=detail&aid=1491459&group_id=10894&atid=310894].
Copyright
This document has been placed in the public domain.
_____________________________________________________________________________
Colophon
TIP AutoGenerator - written by Donal K. Fellows