    <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  :: Francis' Scribbles</title>
        <link>https://members.accu.org/index.php/articles/810</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">Francis' Scribbles from CVu journal + CVu Journal Vol 17, #3 - Jun 2005</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/c184/">Journal Columns</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c181/">Francis' Scribbles</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/c77/">CVu</a>

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

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

                    -                        <a href="https://members.accu.org/index.php/articles/c181+96/">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;Francis' Scribbles</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 06 June 2005 05:00:00 +01:00 or Mon, 06 June 2005 05:00:00 +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="d0e26" id="d0e26"></a>Something
Deeply Unpleasant</h2>
</div>
<p>A couple of people (with regret, one of them a long-term ACCU
member) having been gossiping about a confidential Standard's issue
that concerns Lois Goldthwaite and myself. I do not intend to add
more fuel to an already blazing pyre by going into details
here.</p>
<p>However, &quot;<span class="quote">do not repeat rumours that can
prejudice another professional</span>&quot; is a guideline that should
be automatic among professionals. To that, I would add that anyone
who ignores such a guideline is behaving unprofessionally. Of
course, we all have a tendency to gossip but we should make an
effort to avoid doing so when people's reputations are at stake. We
should also have the professionalism to remind a gossiper firmly
that rumours can have serious consequences.</p>
<p>For the record, I was not a member of the UK delegations to the
recent meetings of WG14 and WG21 at Lillehammer. I actually
attended both those meetings representing Plum Hall (Tom Plum's
Hawaiian based company) and as a reciprocal liaison between WG14
and WG21. However, you should not make any deductions from that,
though some seem to wish to do just that. You should also note that
Lois Goldthwaite attended the WG21 meeting as HoD for the UK. She
is a well-respected member of the International Standard's
community and the editor of the Performance TR. Any suggestion that
she would not have been part of the UK delegation to WG21 is
clearly ludicrous.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e38" id="d0e38"></a>The Evolution
of C++</h2>
</div>
<p>At the recent meeting of WG21 in Lillehammer (Norway) someone
commented that evolution took place by random mutation rather than
by intelligent design. So perhaps Bjarne Stroustrup should be given
the title 'Random Mutator of C++.'</p>
<p>Joking aside, there are many proposals for change and
enhancement of C++ on the table. These are not exactly random but
they do depend upon what matters enough to individuals for them to
take time writing a paper making a proposal. There are probably
many other good ideas that just have not been put forward.</p>
<p>If you have something that you feel you want to be considered
then you have very little time left. We decided in Lillehammer that
we definitely would not consider new proposals for change to the
core of the language made after the pre-meeting mailing for the
October meeting. It would also be fair to warn you that we are
making no guarantee to consider new proposals made between now and
then, just that we will not reject them out of hand. At this stage,
writing a paper and expecting someone else to present it for you
will be a waste of time. If you do not care enough to be at the
meetings to promote your proposal, it will simply die (unless
someone else feels that it has a great deal of merit)</p>
<p>The current number of proposals is extensive. The vary from very
simple additions and changes to keep C and C++ in line with each
other (for example, adding long long - yes you may hate it but
continued resistance would simply use energy that is better spent
elsewhere) to extensive proposals such as those for concepts. We
have come a long way since the early meetings of the evolution
group three years ago. We are beginning to see what it is that we
want to achieve. I have little doubt that some of the newer
participants will feel hurt when we do not select their proposals.
Several of these people have specifically joined WG21 so that they
could promote an idea that they believe to be valuable. These
people are probably right, but that does not mean that the value
will be great enough to incorporate them into the next version of
C++.</p>
<p>Now we have all the mutations, sorry proposals, on the table we
enter into the phase of natural selection. There is no reasonable
way that all the excellent proposals will make it into the next
version of C++.</p>
<p>I often suspect that most people have little idea of how much
work goes into adding even the simplest feature. No one doubts the
good intentions and hard work of those making proposals but they
have to realise that they are asking other people to do a great
deal of work as well. Simple assurances that something will work as
described are not enough.</p>
<p>If you have the slightest doubt about this, consider ADL
(argument dependant look-up). The original proposal for this came
from a highly respected source and it was only after several years
of intense experience that the holes began to show. We do not want
to make the same kind of mistake again. C++ is not some instant
language that can be fixed on the fly or by the next release from
its owners. C++ is a language for serious programming and needs
stability if it is to meet the needs of its users. Changes to a
widely used language are expensive if the language is used for
anything other than instant programming for instant disposal.</p>
<p>Now, even if you have not made any proposals for changes and
additions to C++ you can do your bit to help the selection process.
Have a look at the proposals (see <a href=
"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/" target=
"_top">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/</a>) and
decide which ones look particularly attractive to you. When you
have done that, offer to help those making the proposal. If you
want something, be willing to give it a push to try to get it
further up the ladder.</p>
<p>Get involved, pick a proposal you like and write a short (or
long if want to) piece explaining why you would like to see it in
C++. Send it to me and I will both see it is published here and
that those concerned with WG21 see it. We cannot do design by
democratic vote but that does not mean that we do not listen to the
opinions of users.</p>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e62" id="d0e62"></a>Nomeclature</h3>
</div>
<p>I find terminology is one of the irritating problems with
programming in general and language standards in particular. I am
in the midst of writing my second book and want to be careful to
use the correct terms so that readers will not be confused by
colloquial usage that is at variance with correct usage. However, I
find this to be difficult to do in practice.</p>
<p>I am happy with the distinction between declarations (about
names) and definitions that provide a meaning for a name. Perhaps
it is unfortunate that:</p>
<pre class="programlisting">
int foo();
</pre>
<p>is a declaration, whilst:</p>
<pre class="programlisting">
int i;
</pre>
<p>is usually a definition (as well as a declaration). The
insistence on calling:</p>
<pre class="programlisting">
class x;
</pre>
<p>a forward declaration further clouds the issues. Surely, that is
just a declaration. What is making it even harder to write about
C++ is describing what the sort of thing we are declaring in each
of the following (in other words what kind of name are we
introducing):</p>
<pre class="programlisting">
int i;
int&amp; i_ref (i);
int bar(int parm, int &amp; parm_ref);
</pre>
<p>I think most of us would agree that <tt class="varname">i</tt>
is a variable. In most, but not all contexts, <tt class=
"varname">i</tt> designates specific storage for an integer value.
However, what kind of thing is <tt class="literal">i_ref</tt>? I am
sure that most people are happy to call that a variable as well. It
behaves like a variable; it looks like a variable and so on.
However, according to the strict letter of the C++ Standard it is
not a variable but a reference. References may look like variables
but they are something else. What makes it much worse is that the
Standard wants to talk about <tt class="literal">i_ref</tt> as a
reference that refers to <tt class="varname">i</tt>. That is not
true either; <tt class="literal">i_ref</tt> is a name that
designates the same object that <tt class="varname">i</tt>
designates.</p>
<p>Does all this precision help us talk and think about our code?
From where I am sitting, C++ has objects and names. Names designate
objects (they can also designate other entities such as types and
functions). It is possible to have an object that is not named (we
often call these temporaries, but that is not strictly correct
because dynamically created objects are also nameless).</p>
<p>References always refer to objects; variables always refer to
objects. The difference between them is that a reference is bound
to an existing object at the point of definition but a variable is
bound to a newly created object at the point of definition.
Confused? Well I am. I have to be extraordinarily pedantic if I am
to avoid misspeaking.</p>
<p>What is wrong with referring to a name that designates an object
as a variable? In almost every circumstance, a variable and a
reference are interchangeable. If it looks like a variable and
behaves like a variable let us call it a variable. Let us use the
term 'variable' for any name that designates an object. That should
include parm and parm_ref in the function declaration above.</p>
<p>Why should we care? We should try to avoid such messes as those
created by the many authors who confuse 'declaration' and
'definition'. That lead to the silly term 'forward reference'
because so many writers used the term 'class declaration' when they
meant 'class definition'.</p>
</div>
<div class="sect2" lang="en">
<div class="titlepage">
<h3><a name="d0e114" id="d0e114"></a>Reference
Type</h3>
</div>
<p>Is there such a thing as a reference type? We have pointer types
which are quite distinct from the type to which they point. We also
have <tt class="literal">const</tt> and <tt class=
"literal">volatile</tt> types. Those are also different to the type
they qualify. But my question is whether there is any such thing as
a reference type, or is the term just a lazy way of talking about a
reference to a type.</p>
<p>For example:</p>
<pre class="programlisting">
int i(0);
int * i_ptr(&amp;i);
int &amp; i_ref(i);
</pre>
<p><tt class="varname">i</tt> is of type <tt class="type">int</tt>;
<tt class="literal">i_ptr</tt> is of type <tt class=
"type">int*</tt> (pointer to <tt class="type">int</tt>). However,
what is the type of <tt class="literal">i_ref</tt>? Surely, it is
of type <tt class="type">int</tt>. Or is it? Is there any way that
we can distinguish between a reference and a variable? Yes, this
connects back to my problem with distinguishing between names that
are variables and names that are references.</p>
<p>Both <tt class="varname">i</tt> and <tt class=
"literal">i_ref</tt> identify an object of type <tt class=
"varname">int</tt>. Once we get into user defined types a reference
has the property that it has two types, the static type (the type
it is declared as) and its dynamic type (the type of the object it
references). These two types do not have to be the same. However,
notice that we write about the static and dynamic types of a
reference but we do not say that either of these is a reference
type. So I ask again, is there any such thing as a reference type
in C++.</p>
<p>I am coming to the conclusion that there is not but I would very
much like to hear your opinion before I finally commit myself in my
new book. I have no problem with writing that something is a
reference type in an informal situation but when I am trying to
explain the C++ type system I do want to be correct.</p>
<p>I think that as long as we carefully explain terminology that
using a short cut is perfectly acceptable. As long as we have
stated the difference between a name being a variable and a name
being a reference we should be allowed to shorten the phrase
'variable, reference, parameter or reference parameter' to
'variable'. Just as writing definition is a legitimate abbreviation
for 'declaration and definition.'</p>
</div>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e166" id="d0e166"></a>PC Notes
Taker</h2>
</div>
<p>From time to time, I come across pieces of hardware that seem to
show some promise. One of my on going irritants is that
manufacturers often fail to understand their product and so fail to
make full use of it.</p>
<p>The hardware for this product is very simple. It consists of a
special pen that signals its location when the nib is pressed for
writing (with a cartridge of ordinary biro type ink) and a clip
similar to that you have on a clipboard. All the special
electronics is hidden in the clip and receives the pens signal. It
transmits the information about the pen location to the PC through
a USB connection.</p>
<p>It comes with some special software to handle the data supplied
via the USB port. This allows you to draw on an ordinary sheet of
A4 paper held in the clip, an application program captures what you
draw on the paper. Out of the box, that is it. There are a couple
of extra programs available on the web site and if you have
Microsoft's handwriting-to-text engine one of these allows you to
write on the paper and have it converted to text. That is quite
impressive, but the Microsoft software is doing most of the
work.</p>
<p>The first thing to note is that this product is MS Windows
specific. The provided software is of no use if you have an Apple
machine or a Linux based PC. That is silly; it is not that hard for
a reasonable programmer to supply software for the other common
operating systems.</p>
<p class="c2"><span class="remark">[It is not that simple, mainly
due to the way that different operating systems access hardware and
to my knowledge, there is not any platform independent way to do
this - PFJ]</span></p>
<p>The next problem is that the software interferes with some other
uses. I have to remember to exit from the support software if I
want to play most modern computer games, because the supplied
software puts the game into sleep mode. Not a big problem, but one
that could and should have been avoided. Moreover, I wonder what
other software will have similar problems of co-existing with the
PC Notes Taker software.</p>
<p>Now the big issue is why they think that they should be selling
such a limited set of applications for their hardware. Given the
way the product works, it clearly has the potential to be a mouse
substitute. Even better, we could use the product to create a form,
print out multiple copies and use those for capturing data. The
handwriting to text would convert from the handwritten paper copy
to an electronic version.</p>
<p>I am guessing, but I think there are a good number of people who
would welcome such a tool.</p>
<p>If the manufacturer published the interface information for the
hardware all the above problems would be solve. There are dozens of
competent programmers who would jump at the chance to add value to
the hardware. As it is, the product will have a minuscule market,
remain relatively expensive and will die as things like tablet PCs
become popular and cheaper.</p>
<p>When will the industry learn that trying to do everything
results in an uncompetitive product? Let others enhance your
product and you end up with lots of sales without too much
investment. Just look at what happened to the PC once IBM gave up
trying to control it.</p>
<p>Even better, letting others write extra software promotes the
product because the software will help make the hardware better
known. If I see a piece of software that solves a problem for me if
I buy a relatively cheap peripheral, I am quite likely to make the
purchase. Software sells hardware, the reverse is very rarely the
case.</p>
<p>If you have experience of this product or products like it, I
would be happy to hear from you and publish your comments and
experiences for the benefit of others.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e194" id="d0e194"></a>Problem
20</h2>
</div>
<p>Here is a miniscule program. Now I think it is clear what the
programmer intended but what do you think a conforming compiler
will do with it and why? How should the author have written the
definition of <tt class="literal">p</tt>?</p>
<pre class="programlisting">
 struct data {
      int i;
      int j;
 };
 int main() {
      data** p = new (data*)[5];
 }
</pre></div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e204" id="d0e204"></a>Commentary on
Problem 19</h2>
</div>
<p>What is the portability problem with the following small C++
program?</p>
<pre class="programlisting">
#include &lt;iostream&gt;

int main(){
  std::cout &lt;&lt; &quot;Hello World&quot; &lt;&lt; std::endl;
}
</pre>
<p>At first sight, there seems to be nothing wrong with that
program and I guess you will find it (with minor variations) in
almost every introductory text on C++. However whether a compiler
will compile it depends on the implementation.</p>
<p>The problem, which comes as a surprise to a great number of C++
experts is that there is no requirement in the standard for the
<tt class="filename">iostream</tt> header to include either
<tt class="filename">istream</tt> or <tt class=
"filename">ostream</tt>. Without the <tt class=
"filename">istream</tt> header the compiler will not find a
declaration of appropriate versions of <tt class=
"methodname">operator&lt;&lt;</tt> nor of <tt class=
"literal">std::endl</tt>.</p>
<p>Now we can make a good case for such omissions because, for
example, a programmer might not want to suck in the whole of
<tt class="filename">istream</tt> just to use <tt class=
"literal">std::cout</tt>. However, the result is to create a
surprise for programmers the first time they meet an implementation
of <tt class="filename">iostream</tt> that does not include
<tt class="filename">istream</tt> and <tt class=
"filename">ostream</tt>.</p>
</div>
<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e250" id="d0e250"></a>Cryptic Clues
for Numbers</h2>
</div>
<p>Here is last issue's clue:</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>A first course on C++ at the University of Rome [3 digits]</p>
</blockquote>
</div>
<p>I guess that many of you found that a tough clue. The two parts
of the clue are interwoven. First clue consists of 'first course'
and 'University'. The second part is 'C++' and 'Rome'. Both give
101 as the answer (i.e. 100 + 1).</p>
<div class="blockquote">
<blockquote class="blockquote">
<p>Twice lucky? Thrice lucky? About when China ruled the seas.</p>
</blockquote>
</div>
<p>Note that the second part of this clue will not be general
knowledge for most people. But if you can get the first part,
Google will help confirm it.</p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
