    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: Exception Specifications</title>
        <link>https://members.accu.org/index.php/journals/573</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>


        <h2>Journal Articles</h2>


<div class="xar-mod-head"><span class="xar-mod-title">Overload Journal #29 - Dec 1998</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/journals/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c78/">Overload</a>

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c199/">29</a>
                    (12)
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;Exception Specifications</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 27 December 1999 17:23:23 +00:00 or Mon, 27 December 1999 17:23:23 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="section" lang="en">
<div class="titlepage">
<h2><a name="d0e14" id="d0e14"></a></h2>
</div>
<p>Dear Readers,</p>
<p>Some of you may be happy to see that I have little to say this
time as pressures of the real World have strongly curtailed the
time I have for writing. The following is a response to the letter
from Will Watts.</p>
<p>Will is, of course, entirely correct. I should have said 'the
first of these mechanisms'. I think I must have had a mental spasm,
as it was the first thing in the list but the last thing I wrote
about in the preceding paragraph.</p>
<p>The next comment really embarrasses me. I can only plead that
writing articles while nursing a child with toothache is not
conducive to error free code. Perhaps that also explains my
perverse negativity.</p>
<p>On his last point, I completely agree. What I was attempting to
outline was some mechanism (coding guidelines) that would make use
of exception specifications useful.</p>
<p>A dialogue with Francis has persuaded me that the Standards
Committees have a lot of work to do.</p>
<p>The first thing they need to do is to remove the requirement for
runtime checking of Exception Specifications (ES). We really need
something that will provide us the same choices as we had with the
C <tt class="function">assert()</tt>. Obviously it cannot be done
the same way but we need the ability to have ES in our code for
static checking but leave it out for release versions of
executables. Why leave it out? Because supporting ES has a
measurable influence on code size and execution speed.</p>
<p>The other oft quoted problem of terminate being called by
<tt class="function">unexpected()</tt>, that is easily fixed by
using <tt class="function">std::set_unexpected</tt> to change the
default behaviour to <tt class="literal">throw
std::bad_exception()</tt>.</p>
<p>What I want to provide is a mechanism by which exceptions are
handled at whatever level that the programmer can do so.
Application programmers should not expect to handle low level
problems, generally the next level should handle these. I could
always convert unknown exceptions (those introduced by new releases
of a library and so not handled by older client code) by converting
them to <tt class="exceptionname">std:: bad_exception</tt> but I
na&iuml;vely thought there might be some benefit from doing
otherwise.</p>
<p>Apart from the problem of ES impacting on performance issues
(actually empty throw specifications can result in slimmer, faster
code) there is also the problem of templates. We clearly need a
whole raft of extra requirements if we are to handle ES in template
code. For example:</p>
<pre class="programlisting">
template &lt;typename T&gt; void fn(T t) ???
{
  t.dosomething();
}
</pre>
<p>How do I specify that <tt class="function">fn()</tt> is to
inherit the ES of the member function <tt class=
"function">dosomething()</tt> that belongs to the specific type
<tt class="type">T</tt> for which <tt class="function">fn()</tt> is
being instantiated.</p>
<p>At the moment templates slap a great big barrier across all uses
of ES.</p>
<p>Then there is the issue that Francis tells me WG21 &amp; J16 are
going to address, 'is the exception specification' part of the type
or not? Sometimes it seems that it is and other times it seems it
isn't (can't be used in <tt class="literal">typedef</tt>'s but are
applied to virtual function overriders)</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
