<?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 18 19:31:13 GMT 2013 -->
<!-- TIP AutoGenerator - written by Donal K. Fellows -->

<TIP number='53'>
<header><title>Addition of &apos;assert&apos; Command</title><author address="mailto:Gerald.Lester@aspentech.com">Gerald W. Lester</author><author address="mailto:kennykb@acm.org">Kevin Kenny</author><status type='project' state='withdrawn' tclversion="8.4" vote='prior'>$Revision: 1.4 $</status><history></history><created day='14' month='aug' year='2001' /><keyword>bytecode compiler</keyword></header>
<abstract>This TIP proposes the addition of an <emph style="italic">assert</emph> command and supporting infrastructure to the Tcl core.</abstract>
<body><section title="Rationale">
<para>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 &quot;compiled out&quot; 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.</para>
<para>If, doing byte code compilation, an assert command is encountered the byte code stream generated will be dependent on the value of the <emph style="italic">assert_enabled</emph> 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.</para>
<para>Similarly, if the interpreter encounters an <emph style="italic">assert</emph> command (either compiled or uncompiled), it will only execute it if the <emph style="italic">assert_enabled</emph> command line option is true.</para>
<para>It is acceptable for the compiler to throw an error if the <emph style="italic">booleanExpression</emph> is not brace quoted.</para>
</section>
<section title="Tcl-Level Specification">
<para>The manual entry for the <emph style="italic">assert</emph> command is included here:</para>
<rule/>
</section>
<section title="NAME">
<quote>assert - Assert a run time validation condition</quote>
</section>
<section title="SYNOPSIS">
<verbatim><vline encoding='base64'>ICAgYXNzZXJ0IGJvb2xlYW5FeHByZXNzaW9uIG1lc3NhZ2VUZXh0</vline></verbatim>
</section>
<section title="DESCRIPTION">
<quote>This command has no effect if the assert_enabled command line option is not true at both compile and run time. If the <emph style="italic">assert_enabled</emph> command line option is true at both compile and run time, the following behavior will occur:</quote>
<enumerate><item.e index='1'><para>The <emph style="italic">booleanExpression</emph> will be evaluated</para><enumerate><item.e index='2'><para>If the <emph style="italic">booleanExpression</emph> evaluates to a true value, <emph style="italic">assert::failed</emph> will be called at the global level with <emph style="italic">messageText</emph> as its one and only parameter.</para><para>The default implementation of <emph style="italic">assert::failed</emph> will write <emph style="italic">messageText</emph> to standard out and <emph style="italic">exit</emph> with a status code of 1.</para></item.e></enumerate></item.e></enumerate>
<rule/>
</section>
<section title="Remarks">
<para>This TIP has been withdrawn because of other changes, both inside and outside the Tcl core.</para>
<enumerate><item.e index='1'><para>The bytecode compiler (8.4a4) contains code that recognizes a no-op procedure of the form <emph style="italic">proc no-op args {}</emph> and generates no bytecode if such a procedure is called with arguments that have no side effects.</para></item.e><item.e index='2'><para>The <emph style="italic">control</emph> package within tcllib implements a <emph style="italic">::control::assert</emph> procedure that provides all the requested functionality.</para></item.e></enumerate>
<para>These two, taken together, provide an implementation of the requested functionality that is acceptable to the original author of this TIP.</para>
</section>
<section title="Copyright">
<para>This TIP is in the public domain.</para>
</section>
</body></TIP>
