    <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 Wall</title>
        <link>https://members.accu.org/index.php/articles/966</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">Letters to the Editor + CVu Journal Vol 12, #1 - Jan 2000</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/c186/">LettersEditor</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/c128/">121</a>
<br />

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

                    -                        <a href="https://members.accu.org/index.php/articles/c186+128/">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 Wall</h1>
<p><strong>Author:</strong>&nbsp;</p>
<p>
<strong>Date:</strong> 08 January 2000 13:15:34 +00:00 or Sat, 08 January 2000 13:15:34 +00:00</p>
<p><strong>Summary:</strong>&nbsp;</p>
<p><strong>Body:</strong>&nbsp;<div class="sect1" lang="en">
<div class="titlepage">
<h2><a name="d0e22" id="d0e22"></a>And Further
Corrections</h2>
</div>
<p>Dear Francis,</p>
<p>Re: You Write, the Editor Replies - C Vu 11.6</p>
<p>It's that ISBN stuff again... In your reply (to Catriona?) about
the removeDashes function you say that you would prefer to code
that function as:</p>
<pre class="programlisting">
char[]  removedashes (char sourcestring[]) {
  int i=0;  
  int j=0;
  while (sourcestring[i] == sourcestring[++j])
    if (sourcestring[i] != '-' )  ++i;
  return sourcestring;
}
</pre>
<p>I assume there was a typo in that while expression, since as it
stands it will patently fail with the == and the pre-increment of j
(I think...) You asked what readers think - here are my
thoughts.</p>
<div class="orderedlist">
<ol type="1">
<li>
<p>change that while expression to:</p>
<pre class="programlisting">
  while (sourcestring[i] = sourcestring[j++] )
</pre>
<p>has a better chance of working! I have no gripes about omitting
the comparison with '\0' (though I know of others that have
stronger views on the subject!).</p>
</li>
<li>
<p>That said, If I had to code a removedashes() it would look more
like:</p>
<pre class="programlisting">
char* removedashes(char *source) {
  char *p,      /* for reading bytes from 'source' */
      *q;      /* for writing back bytes to 'source' */
  for(q = p = source; *p; ++p) if (*p != '-') *q++ = *p;
  *q = '\0';  /* terminate resulting string */
  return source;
}
</pre>
<p>I think the choice of while/for is personal, but I'm not so sure
about the choice of [] (array) or * (pointer) for the declarations.
To my mind, either is acceptable in the above context, and I
personally find the '*' declarations more readable. And at the risk
of being pedantic, find the '*' more descriptive - in the sense
that removedashes() returns the address of the first element of an
array rather than the array itself; i.e. a pointer value. I'm happy
to be shot down in flames for this heresy, but the above function
does work as expected (for me!).</p>
</li>
<li>
<p>The eliminate() question. Here's my version:</p>
<pre class="programlisting">
#include &lt;stdio.h&gt;  /* for def'n of NULL */
#include &lt;string.h&gt;  /* for def'n of strchr() */
char* eliminate (const char *these, char *from) {
char  *p,    /* for reading bytes from 'from' */
    *q;    /* for writing back bytes to 'from' */
  for (q = p = from; *p; ++p) {
    if (strchr (these, *p) == NULL) *q++ = *p;
  }
  *q = '\0';  /* terminate resulting string */
  return from;
}
</pre></li>
</ol>
</div>
<p>This is maybe not the most efficient solution, but at least it
works, given of course that *these or these[] reference a
null-terminated array of char - a reasonable assumption I think
given the specified prototype with no size parameter. Without this
assumption strchr() would be inappropriate :-( (I also took the
liberty of adding a const in there on the grounds that I think
these[] should not be changed by the function.)</p>
<p>However, a function to eliminate certain characters might well
be optimised (e.g. for speed) in a real-life situation where
these[] was effectively a &quot;fixed&quot; set of unwanted chars. In such a
case I'd be tempted to set up an array of 256 elements (unsigned
bytes for speed, bits for space) and use an indexed lookup to
replace the many calls to strchr. Thus there would be a once-off
initialisation function to set up e.g. the discard[] array with
TRUE/FALSE elements, and the</p>
<p>if (strchr (these, *p) == NULL)</p>
<p>line would be replaced with something like</p>
<p>if (! discard [*p] )</p>
<p>And if I had the choice I'd make sure that all 'char's were
unsigned - either by explicit declaration or compiler switch. I've
been bitten too many times using signed chars in such
situations!</p>
<p>Hope there's something here that's usable for C Vu,</p>
<p>Pete Disdale <tt class="email">&lt;<a href=
"mailto:pete@pdlmail.demon.co.uk">pete@pdlmail.demon.co.uk</a>&gt;</tt></p>
<i><span class="remark">Thanks. One of those errors was a typo. The
use of char[] for a return type was done with malice aforethought.
Now a word about [] versus * in parameter declarations. I strongly
advocate the [] in the prototype in the header file and in
documentation because it tells the user something vital, this
function processes an array. I prefer to use pointer notation in
the definition (implementation file) to remind me that this is how
the local code sees it.</span></i>
<p class="c3"><span class="remark">I slightly changed the layout of
your code. However when using structures (loops etc.) I advocate
using braces for the controlled statement unless it will fit on a
single line. Some insist that braces are always used. Personally I
find that less helpful. Finally I always place cv (const, volatile)
qualifiers to the right of what is being qualified. 'No exceptions'
leads to 'no surprises'.</span></p>
</div>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
