<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE TIP SYSTEM "http://www.tcl.tk/cgi-bin/tct/tip/tipxml.dtd">
<!-- Converted at Sat May 25 05:31:02 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='269'>
<header><title>Add &apos;string is list&apos; to the &apos;string is&apos; Subcommand</title><author address="mailto:joe@mistachkin.com">Joe Mistachkin</author><status type='project' state='final' tclversion="8.5" vote='after'>$Revision: 1.7 $</status><history></history><created day='19' month='may' year='2006' /><keyword>Tcl lists strings</keyword></header>
<abstract>The <emph style="bold">string</emph> command supports tests for a number of Tcl&apos;s basic types, for example, integers, doubles, and booleans. This TIP proposes adding lists to the set of things that can be checked for.</abstract>
<body><section title="Rationale">
<para>The <emph style="bold">string</emph> command includes tests for the common Tcl types: <emph style="bold">string is boolean</emph>, <emph style="bold">string is double</emph> and <emph style="bold">string is integer</emph>. Unaccountably, <emph style="bold">string is list</emph> is missing from the list, making it difficult for an input validation procedure to determine whether, in fact, a string contains a proper list.</para>
<para>Currently, something similar to the following incantation is required:</para>
<verbatim><vline encoding='base64'>IHNldCBpc19saXN0IFtleHByIHshW2NhdGNoIHtsbGVuZ3RoICRzdHJ9XX1d</vline></verbatim>
<para>The above construct (and others like it) are extremely counterintuitive, especially to people without intimate knowledge of Tcl.</para>
<para>Compare and contrast with:</para>
<verbatim><vline encoding='base64'>IHNldCBpc19saXN0IFtzdHJpbmcgaXMgbGlzdCAkc3RyXQ==</vline></verbatim>
<para>Since <emph style="bold">string is</emph> 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.</para>
</section>
<section title="Specification">
<para>This document proposes augmenting the <emph style="bold">string is</emph> command with a <emph style="bold">string is list</emph> subcommand, as follows:</para>
<quote><emph style="bold">string</emph> <emph style="bold">is</emph> <emph style="bold">list</emph> ?<emph style="bold">-strict</emph>? ?<emph style="bold">-failindex</emph> <emph style="italic">var</emph>? <emph style="italic">str</emph></quote>
<para>The result will be <emph style="bold">1</emph> if the string has proper list structure; otherwise, it will be <emph style="bold">0</emph>. The option <emph style="bold">-strict</emph> is accepted for syntactic compatability with other forms of <emph style="bold">string is</emph> but has no effect since empty strings are proper lists.</para>
</section>
<section title="Reference Implementation">
<para>A reference implementation of this TIP is available [<url ref="http://sf.net/tracker/?func=detail&amp;aid=1491459&amp;group_id=10894&amp;atid=310894"/>].</para>
</section>
<section title="Copyright">
<para>This document has been placed in the public domain.</para>
</section>
</body></TIP>
