    <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  :: The Casting Vote</title>
        <link>https://members.accu.org/index.php/journals/607</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 #6 - Mar 1995 + Programming Topics</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/c177/">06</a>
                    (8)
<br />

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

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

                     &gt;                         <a href="https://members.accu.org/index.php/journals/c65/">Programming</a>
                    (877)
<br />

                                            <a href="https://members.accu.org/index.php/journals/c177-65/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/journals/c177+65/">All of these categories</a>
<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;The Casting Vote</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 27 March 1995 18:22:19 +01:00 or Mon, 27 March 1995 18:22:19 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e20" id="d0e20"></a></h2>
</div>
<p>Valley Forge, Pennsylvania. The scene of some famous battles.
November 1994 saw the latest meeting of X3J16/WG21 at the
Convention Center nestled between some freeways in a particularly
pedestrian-unfriendly manner. Perhaps in keeping with the spirit of
the location, some skirmishes were fought between factions of the
joint C++ committee. Unfortunately, there were over 'minor' issues
of syntax with some added political spice thrown in.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e24" id="d0e24"></a>History in the
making</h2>
</div>
<p>However, history was made in a way, when the joint committee
voted to remove parts of the draft standard library - whoever heard
of such a thing? We all know that standards committees only add
stuff, don't they? Under the hammer this time were early attempts
at container classes and some of the more baroque parts of the
streams library.</p>
<p>With the introduction of STL in July 1994, we now have a very
consistent framework under-pinning the library and efforts are
being made to coerce other parts of the library into the 'style' of
STL - templatising strings and streams, adding iterators and
generally making the class interfaces more consistent. STL provides
a vector container which makes the classes bit_string, dyn_array
and ptr_dyn_array redundant since the former can be replaced by
vector&lt;bool&gt; and the latter by vector&lt;T&gt; and
vector&lt;T*&gt; respectively with no loss of functionality.</p>
<p>The streams library also underwent some minor surgery with the
loss of stdiostream in favour of fstream. The intent of stdiostream
had been to aid mixed stdio / streams programs but the semantics of
fstream have been gradually changed so that such help is no longer
necessary. Another victim of the streams library's growing pains is
strstream - the sscanf / sprintf of the streams world - which has
been deprecated (i.e., marked for potential removal in a future
version of the standard) because stringstream provides a safer
alternative using the library class string.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e33" id="d0e33"></a>Exceptional
politics</h2>
</div>
<p>The UK have raised the objection that exceptions break pretty
much every program written. The following code fragment is a good
example of how exceptions break things:</p>
<pre class="programlisting">
void f()
{
  T* p = new T;
  // some processing
  delete p;
}
</pre>
<p>If the processing causes an exception to be thrown, the
statement delete p; is never reached leading to a memory leak. To
make this code &quot;exception-safe&quot; requires adopting the
&quot;initialisation is acquisition&quot; idiom associated with resource
management:</p>
<pre class="programlisting">
class T_handle
{
public:
  T_handle(T* pp)
  : p(pp) { }
  ~T_handle()
  { delete p; }
  operator T*()
  { return p; }
private:
  T* p;
};
void f()
{
  T_handle p(new T);
  // some processing
  // p automatically
  // deleted when it
  // goes out of
  // scope or when
  // exception thrown
}
</pre>
<p>The UK viewed this as such a fundamental idiom that we required
a solution before we would vote &quot;yes&quot; in the Committee Draft
Registration ballot (currently in progress - see &quot;The Casting Vote&quot;
in CVu7.1 for more details of the ballot process). Greg Colvin has
produced several proposals covering &quot;smart pointers&quot; and garbage
collection and the committee finally adopted one of his proposals
in an effort to satisfy the UK and other ISO members. The class
template is called auto_ptr and is used in a similar manner to the
example above. He also proposed counted_ptr which can be used to
underpin a reference-counted object, but this was presented in a
somewhat unconvincing light by the chair of the Library WG who
disapproves of what he considers &quot;ISO blackmail&quot; when a &quot;yes&quot; vote
depends on acceptance of some language feature or library class.
This view is shared by several members of the ANSI committee, as I
have commented before, and does not make international
consensus-building any easier. The effect was that the ANSI vote
went against counted_ptr but the ISO vote was in favour. After some
political manoeuvring which saw various countries changing their
votes in an attempt to improve consensus, the motion was withdrawn
with an agreement to bring it back for a vote in Austin, TX in
March 1995. The battle is still being fought on the committee
reflectors but at least some of the political aftertaste has worn
off.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e46" id="d0e46"></a>Exceptional
contracts</h2>
</div>
<p>What do exception specifications do for you? The answer is
probably &quot;not much&quot;. You can specify in a function declaration what
exceptions a function can throw but how much confidence can you
have in such a declaration? Until Valley Forge, the answer was
&quot;very little&quot;. The reason is that when the compiler sees an
exception specification, it has to generate code to trap any other
exceptions and call unexpected(). That function in turn can throw
any exception it fancies, thus breaking the contract suggested by
the function's exception specification. This was another UK
bug-bear and possible solutions involved removing exception
specifications from the language or having them compile-time
checkable, neither of which won universal favour with the
committee. In the end, the Extensions WG provided an acceptable
half-way house: unexpected() may not throw anything that would
break the contract. This means that a compiler can perform
reasonable checking on exception specifications and provide
optimisations where it can establish that unexpected() cannot be
called. This in turn makes using exception specifications much more
attractive and seems to satisfy several different groups all at
once.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e51" id="d0e51"></a>Templates - and
where to stick 'em</h2>
</div>
<p>Probably the most difficult as&shy;pect of portable C++
program&shy;ming is how to organise your template code o that it
compiles on a variety of platforms. (Unless, of course, you happen
to be a Microsoft C++ programmer in which case you don't have to
worry about such things unless you have NT and can run VC++2.0) For
Borland programmers this is predetermined - you simply include all
your definitions and the compiler figures it all out for you. For
Cfront programmers it is also well-defined - if your declarations
are in x.h, your definitions live in x.c. This is fine until you
try to port code between those two environments so for
multi-platform tool vendors it is a real and very costly issue.</p>
<p>Template compilation was another issue that the UK felt very
strongly about and the Extensions WG have worked very hard to come
up with a possible solution. To be more precise, Bjarne Stroustrup
has worked very hard on this. The previous best effort was a new
directive that told the compiler where to look for template
definitions. This was a compromise between a preprocessor directive
favoured by some compiler vendors and a completely automatic, or
magical, system preferred by others (and most users). In the end,
the scheme adopted means that templates behave pretty much like
everything else in the language. Declarations live in header files
and definitions live in source files. You can put definitions in
header files if you want - they have to be static or inline -
because they behave just like non-templates. While this makes life
much easier for users, it does make life harder for vendors.
Hopefully we will all benefit from this (major) change.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e58" id="d0e58"></a>Being
explicit</h2>
</div>
<p>As you might expect, we voted in another keyword. Before you
start howling, let me step back and give some background. How often
have you been caught out by a constructor with one argument?
Implicit conversions are wonderful when you want them but they have
a tendency to pop up in unexpected places. Consider the following
code fragment:</p>
<pre class="programlisting">
void f(string);
f(5);
</pre>
<p>Surprisingly, this is a valid call because an implicit
conversion exists from 5 to a string. But what does it do? Does it
create a 5-element string or a single element string with a
character whose value is 5? A good knowledge of the class is needed
to decide, and yet this is likely to be quite common. How can the
class designer prevent these implicit conversions? Current tricks
involve adding a dummy argument which the user must specify or
using an intermediate conversion class. Both these solutions are
&quot;clever&quot;, &quot;ugly&quot; and have slightly undesirable semantics. Nathan
Myers proposed adding the keyword constructor to the language to
specify a non-converting constructor (the keyword destructor was
proposed for symmetry). The proposal was generally well-received.
In fact, Germany had made the issue of non-converting constructors
one of their &quot;no&quot; vote issues. Unfortunately, when the proposal
came up for discussion in full committee, several people objected
to the syntax. Round and round we went, with all sorts of
interesting suggestions until the committee accepted a single new
keyword explicit. You can declare a constructor explicit and it
will no longer be available for implicit conversions.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e67" id="d0e67"></a>Wot! No
Core?</h2>
</div>
<p>Of course the Core WG was busy! This time they worked on object
shape acquisition and the const-ness of objects. They also
revisited polymorphic behaviour during construction. If you find
this a totally fascinating subject, please e-mail me to discuss it
but I'm not going to delve into such a snake-pit in public!</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e72" id="d0e72"></a>Coming
soon...</h2>
</div>
<p>The next Casting Vote column will tell you what happened in
Austin, TX in March 1995. We will know the result of the CDR ballot
then and I should be able to report on whether we started the CD
ballot.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
