\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#269: Add 'string is list' to the 'string is' Subcommand}
\date{May 19, 2006}
\author{Joe Mistachkin}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#269}&\textbf{Add 'string is list' to the 'string is' Subcommand}\\\hline
Author&

Joe Mistachkin \tipmail{joe}{mistachkin.com}
\\
Created&Friday, \(\text{19}^{\text{th}}\) May 2006\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.7 $\\
Keywords&Tcl, lists, strings\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

The \textbf{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.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

The \textbf{string} command includes tests for the common Tcl types: \textbf{string is boolean}, \textbf{string is double} and \textbf{string is integer}. Unaccountably, \textbf{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:
\begingroup\small\begin{verbatim}
 set is_list [expr {![catch {llength $str}]}]
\end{verbatim}
\endgroup

The above construct (and others like it) are extremely counterintuitive, especially to people without intimate knowledge of Tcl.

Compare and contrast with:
\begingroup\small\begin{verbatim}
 set is_list [string is list $str]
\end{verbatim}
\endgroup

Since \textbf{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.

\section{Specification}

This document proposes augmenting the \textbf{string is} command with a \textbf{string is list} subcommand, as follows:

\begin{quote}
\textbf{string} \textbf{is} \textbf{list} ?\textbf{-strict}? ?\textbf{-failindex} \textit{var}? \textit{str}
\end{quote}

The result will be \textbf{1} if the string has proper list structure; otherwise, it will be \textbf{0}. The option \textbf{-strict} is accepted for syntactic compatability with other forms of \textbf{string is} but has no effect since empty strings are proper lists.

\section{Reference Implementation}

A reference implementation of this TIP is available [\url{http://sf.net/tracker/?func=detail&aid=1491459&group_id=10894&atid=310894}].

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
