    <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/articles/1770</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>




<div class="xar-mod-head"><span class="xar-mod-title">Programming Topics + Overload Journal #5 - Sep 1994</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/articles/">All</a>

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

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

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

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

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

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c308/">05</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c65-308/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c65+308/">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;Martin Moene</p>
<p>
<strong>Date:</strong> 11 May 2012 21:17:47 +01:00 or Fri, 11 May 2012 21:17:47 +01:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<!-- Page 18 -->

<p>Overload 4 hit my desk shortly after I returned from San Diego and the most recent meeting of X3J16/WG21. San Diegoâ€™s a beautiful city and this was the first occasion that I had taken time off around a committee meeting to explore. I hope we get back there before weâ€™ve finished the standardisation process. The schedule for future meetings is gradually being laid out and the following international members will be hosting meetings in the next few years: Canada (July â€˜94), Japan (November â€˜95), Sweden (July â€˜96), UK (July â€˜97). In addition, there are two meetings a year in North America â€“ well, the U.S. folks donâ€™t travel too well, you seeâ€¦</p>
<p>The UK meeting will be hosted by my company, and by that time we should be fairly close to an international standard. All the same, it would be nice to see as large a UK contingent present as possible.</p>
<h2>What happened in San Diego?</h2>
<p>The hot topic was the schedule â€“ not just the planned meetings, but the more important issue of how quickly we can produce an International Standard for C++.</p>
<h2>The UK Position</h2>
<p>Prior to the meeting, the UK panel had been reviewing the working paper and had come to the conclusion that it really was a long way off being acceptable as an IS. Accordingly, we took the position that we wanted to slip the schedule by two meetings, or eight months.</p>
<p>By the time myself and Steve Rumsby arrived in San Diego, we had established, informally at least, that the UK position was supported by Germany, Japan, Australia and New Zealand. That meant a majority of the international members supported a slippage. However, we sort of didnâ€™t get itâ€¦</p>
<h2>The â€œmissingâ€ Ballot</h2>
<!-- Page 19 -->

<p>The schedule prior to San Diego said we would be voting in July â€˜94 on whether to advance the working paper into the â€œCD Registration Ballotâ€. This ballot is conducted by SC22 â€“ an international committee for which WG21 is an advisory working group. From there the document would go on to â€œDraft International Standardâ€ and finally â€œInternational Standardâ€, assuming it was successful at each ballot.</p>
<p>Sam Harbison, convenor of WG21, informed us that there was in fact an extra ballot involved between â€œCD Registrationâ€ and â€œDISâ€. Adding this to the schedule pushed the final date out by about eight months.</p>
<p>There ensued a great deal of confusion about exactly what each ballot meant and what the criteria for acceptance at each stage should be. In the end, the â€œpro-slipâ€ group agreed to delay a decision on whether or not to slip until the July meeting. Our main opponent was the U.S. who seems indecently keen to have a standard now and damn the quality. The July meeting will be interesting and will be held, somewhat prophetically, in Waterloo (in Canada!).</p>
<h2>If all goes well</h2>
<p>According to the schedule produced at the end of the San Diego meeting (which was not, perhaps significantly, endorsed by the majority of WG21 members), we should publish our International Standard for C++ early in 1997.</p>
<p>So why did I say that the July â€˜97 meeting will be in the UK? Well, no-one really believes that the document will go through each and every one of the three ballots first time. Even if it did, we would still be answering public interpretation requests for years to come.</p>
<h2>Language changes</h2>
<p>Apart from the schedule, it was business as usual for most of the working groups. Core continued to wrestle with linkage, references and lvalues. Library continued wrestling with iostream and began to get to grips with exceptions. Extensions wrestled with exceptions and templates.</p>
<h2>Iâ€™ve broken it</h2>
<p>Or rather, weâ€™ve finally fixed it: the scope of variables declared in a for loop, that is. You may not thank the committee for it now, but we broke this:</p>
<pre class="programlisting"><code>for(int i = 0; i &lt; LIMIT; ++i)
{
   if (key == table[i])
   {
      break;
   }
}
if (i == LIMIT)
{
// didn't find the key item
}</code></pre>
<p>We have made i go out of scope at the end of the for loop. A lot of code does this, but it is very easy to fix:</p>
<pre class="programlisting"><code>int i = 0;
for ( ; i &lt; LIMIT; ++i)</code></pre>
<p>This restores the original meaning. Why did we change it? A lot of people new to C+ + write something like this and wonder why it doesnâ€™t work:</p>
<pre class="programlisting"><code>for(int i=O;i &lt; LIMIT;++i)
...
for(int i=O;i &lt; LIMIT;++i)
...</code></pre>
<p>The second for loop causes a â€œduplication definitionâ€ compilation error. Furthermore, thereâ€™s a quality issue involved: if you really want to ask whether or not an item is present in the table, shouldnâ€™t you choose a better way than testing the loop variable?</p>
<pre class="programlisting"><code>bool missing = true;
for(int i=0; i &lt; LIMIT; ++i)
{
   if (key == table[i])
   {
      missing = false;
      break;
   }
}
if (missing)
{
   // didn't find the key item
}</code></pre>
<p>Or if you want to work on the found item:</p>
<pre class="programlisting"><code>Item* item = 0;
for(int i = O; i LIMIT; ++i)
{
   if (key == table[i])
   {
      item = &amp;table[i];
      break;
   }
}
if (item)
{
   // work on item-
}</code></pre>
<p>There was another reason â€“ does the following work on your Borland compiler?</p>
<pre class="programlisting"><code>for (int i = 0; int j = (i &lt; LIMIT); ++i)
{
// ...
}
i = j;</code></pre>
<p>While i stays in scope, j should go out of scope. This behaviour is a consequence of the decision to introduce run-time type identification in March â€˜93 and allow declarations in the condition of if, switch, while and for.</p>
<h2>Member constants</h2>
<p>Hopefully, this decision will be more to your liking. Isnâ€™t it annoying that you cannot have typed constants inside a class like you can everywhere else?</p>
<pre class="programlisting"><code>static const int size=42;
class X
{
public:
   static const int mySize = 128; // illegal
private:
   char buffer[mySize];
};</code></pre>
<p>You had to muck about with enum and it didnâ€™t always work. Well, we voted to allow the above example. A static integral data member may now have an initialiser inside the class. You still have to provide the static data member definition outside the class somewhere, and that cannot have an initialiser now, but that will probably get changed before weâ€™re done â€“ let us know what you think.</p>
<!-- Page 20 -->

<h2>Templates</h2>
<p>We resolved another long list of minor template issues, carrying on the work started in San Jose. We also added some extensions to make templates even more useful.</p>
<p>We added the ability to pass templates as arguments to other templates. This allows you to write container class templates and then write a container encapsulation class template for which you can specify different types of containers. An example would probably make this clearer:</p>
<pre class="programlisting"><code>template&lt;class T&gt;
class list;

template&lt;class T&gt;
class dyn_array;

template&lt;class K,class V,template&lt;class T&gt; class C&gt;
class map
{
   C keys; // a C container of K keys
   C values; // a C container of V values
// ...
};

map&lt;g,string,list&gt; mapl;
map&lt;g,string,dyn_array&gt; map2;</code></pre>
<p>This allows more control over the mechanisms used by template classes and will become more important as the use of templates matures.</p>
<p>We also decided to allow some conversions to take place for arguments to template functions. Effectively, this will allow the compiler to perform trivial conversions in order to match a template function. For example:</p>
<pre class="programlisting"><code>template&lt;Class T&gt;
void funcl(T* p)
{
// don't know whether T
// is const or not!
}

template&lt;Class T&gt;
void func2(const T* p)
{
// we know T is const
// now, but we cannot
// call func2 with, for
// example, a 'char*'
// argument - it wouldn't
// match the const-ness
// of the parameter
}</code></pre>
<p>This problem is now solved: you can declare func2 as above and you will be able to call it with a char* argument â€“ the compiler will perform the â€˜trivialâ€™ conversion from char* to const char*.</p>
<p>The final extension we added was to allow member functions to be templates. This solves a problem with writing a safe pointer template class. Consider the following code:</p>
<pre class="programlisting"><code>class base { ... };
class derived : public base { };

derived* dpl = ... ;
base*    bpl = dpl;
// conversion 'derived*' = 'base*'

template&lt;Class T&gt;
class ptr
{
   T* p;
public:
   ptr(const ptr &amp; pp)
   : p(pp.p) [ }
   // ...
};

ptr&lt;derived&gt; dp2 = ... ;
ptr&lt;base&gt; bp2 = dp2; // illegal!</code></pre>
<p>The problem is that there is no relationship between ptr&lt;base&gt; and ptr&lt;derived&gt; â€“ they are just two different classes. Ideally, you want a constructor for ptr that takes something other than a T* but only those types that can be converted to T*. Member templates provide the solution like this:</p>
<pre class="programlisting"><code>template&lt;class T&gt;
class ptr
{
   T* p;
public:
   template&lt;class U&gt;
   ptr(const ptr&amp; pp)
   : p(pp.p) { }
   // ...
} ;

ptr&lt;base&gt; bp2 = dp2;
// valid: T == base,
// U == derived</code></pre>
<p>The initialisation p(pp.p) will be valid only for U* that can be converted to T*, so the ptr constructor allows â€˜normalâ€™ pointer conversions.</p>
<p>We discussed a few more extensions for templates that will probably come up for a vote in Waterloo. These include template typedefs, te mplate name spaces and namespaces as template arguments. These would make templates more orthogonal by removing restrictions on what can be a template.</p>
<h2>Core Language changes</h2>
<p>It was decided to disallow const and volatile qualifiers on the top level of a reference declaration â€“ the following is now ill-formed:</p>
<pre class="programlisting"><code>int i ;
int&amp; const ir = i;</code></pre>
<p>No one seemed to know what such a declaration should mean, so now you canâ€™t write it!</p>
<p>It was decided that the left hand side of . or -&gt; is evaluated, even when the right hand side is a static member. Previously the left hand side was only evaluated if the right hand side was a non-static member.</p>
<pre class="programlisting"><code>class example
{
public:
   static void sf();
   void f( ) ;
} ;

example* g();
g()-&gt;f(); // always calls g()
g()-&gt;sf(); // previously, did not call g(),now it does</code></pre>
<p>This makes the language a bit more intuitive â€“ it certainly needs it!</p>
<h2>Library issues</h2>
<p>Some minor changes were made to the proposed use of namespaces and exceptions within the library. Quite a few â€˜editorialâ€™ changes were agreed for the library section of the draft standard.</p>
<!-- Page 21 -->

<p>The main topic of interest for the library was â€œThe Standard Template Libraryâ€ which was described by its author, Alex Stepanov of Hewlett-Packard.</p>
<p>Although it was not discussed in committee â€“ lack of time â€“ there was a great deal of interest in this work as it would fill some of the holes in the library. STL contains various container classes, such as list, and associated iterators which are missing from the current draft standard.</p>
<p>It also provides a coherent framework for template classes which the draft standard library lacks. Hopefully, there will be a formal proposal to include this into the draft standard at the Waterloo meeting. In the meantime, I have signed up, with several others, to work with STL and report on what I find.</p>
<p>The next Casting Vote column will tell you what happened in Waterloo in July 1994.</p>
<p>Sean A. Corfield</p>
<p>I can be contacted by e-mail: Sean.Corfield@prqa.co.uk</p>
</p>
<p><strong>Notes:</strong>&nbsp;Generated via JPG, Google OCR, pandoc markdown from scanned journal</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
