\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#53: Addition of 'assert' Command}
\date{August 14, 2001}
\author{Gerald W. Lester, Kevin Kenny}
\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 \#53}&\textbf{Addition of 'assert' Command}\\\hline
Author&

Gerald W. Lester \tipmail{Gerald.Lester}{aspentech.com}
\par
Kevin Kenny \tipmail{kennykb}{acm.org}
\\
Created&Tuesday, \(\text{14}^{\text{th}}\) August 2001\\
Type&Project\\
Tcl Version&\(8.4\)\\
State&Withdrawn\\
Vote&Pending\\
Version&\tipversion$Revision: 1.4 $\\
Keywords&bytecode, compiler\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

This TIP proposes the addition of an \textit{assert} command and supporting infrastructure to the Tcl core.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

Many languages, including other scripting languages, have assertion checking features that can be used to assist in validating program correctness. Typically, these assertion checking features can be ``compiled out'' of production systems so as not to impact performance. To have a similar effect in Tcl, the assertion checking features must be implemented at the byte code compiler level.

If, doing byte code compilation, an assert command is encountered the byte code stream generated will be dependent on the value of the \textit{assert\_enabled} command line option. If the option is true, a byte code stream will be emitted to implement the assert command. If the option is not true, no byte code will be emitted.

Similarly, if the interpreter encounters an \textit{assert} command (either compiled or uncompiled), it will only execute it if the \textit{assert\_enabled} command line option is true.

It is acceptable for the compiler to throw an error if the \textit{booleanExpression} is not brace quoted.

\section{Tcl-Level Specification}

The manual entry for the \textit{assert} command is included here:

\vspace{3ex}\hrule\vspace{1.5ex}

\section{NAME}

\begin{quote}
assert --- Assert a run time validation condition
\end{quote}

\section{SYNOPSIS}
\begingroup\small\begin{verbatim}
   assert booleanExpression messageText
\end{verbatim}
\endgroup

\section{DESCRIPTION}

\begin{quote}
This command has no effect if the assert\_enabled command line option is not true at both compile and run time. If the \textit{assert\_enabled} command line option is true at both compile and run time, the following behavior will occur:
\end{quote}
\begin{enumerate}
\item{}
The \textit{booleanExpression} will be evaluated
\begin{enumerate}
\setcounter{enumii}{1}
\item{}
If the \textit{booleanExpression} evaluates to a true value, \textit{assert::failed} will be called at the global level with \textit{messageText} as its one and only parameter.
\end{enumerate}

The default implementation of \textit{assert::failed} will write \textit{messageText} to standard out and \textit{exit} with a status code of 1.
\end{enumerate}

\vspace{3ex}\hrule\vspace{1.5ex}

\section{Remarks}

This TIP has been withdrawn because of other changes, both inside and outside the Tcl core.
\begin{enumerate}
\item{}
The bytecode compiler (8.4a4) contains code that recognizes a no-op procedure of the form \textit{proc no-op args \{\}} and generates no bytecode if such a procedure is called with arguments that have no side effects.
\setcounter{enumi}{1}
\item{}
The \textit{control} package within tcllib implements a \textit{::control::assert} procedure that provides all the requested functionality.
\end{enumerate}

These two, taken together, provide an implementation of the requested functionality that is acceptable to the original author of this TIP.

\section{Copyright}

This TIP is in the public domain.

\section{Colophon}

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