C style peeve and knowing the rules

Peter B. Henderson dbuksba at ic.sunysb.edu
Mon Mar 26 03:41:11 AEST 1990


In article <19356 at megaron.cs.arizona.edu> robert at cs.arizona.edu (Robert J. Drabek) writes:
>In article <340018 at hplvli.HP.COM>, boyne at hplvli.HP.COM (Art Boyne) writes:
>> jgk at osc.COM (Joe Keane) writes:
>> >Here's my biggest C style peeve.  For some reason, many C programmers insist
>> >on always putting parentheses around return values, even when they're not
>> 
>> Also, 'while', 'for', 'if', etc.,
>> all *require* parenthesis, so it's a reasonable habit to acquire.
>
>But as Joe Keane said, these constructs require the parenthesis for a
>particular reason and few people understand that reason.
>
>Also, Joe Keane made the point that many people put parenthesis in
>simply because they see other people do it.  And there are those who
>believe return is a function and hence required!
>
>I require my students to use the absolute minimum number of parenthesis
>until they have ALL the rules down pat.  After leaving my courses (or in
>the privacy of their own PC) they'll do whatever feels good, but I will
>have done my job as well as I can by getting them to understand these
>details.
>
>Please, I know parenthesis are sometimes an aid in producing readable
>code and they are also clutter which can make for less-readable code.
>-- 
>Robert J. Drabek                            robert at cs.Arizona.EDU
>Department of Computer Science              uunet!arizona!robert
>The University of Arizona                   602 621 4326
>Tucson, AZ  85721


  Being a student as well as a software developer, I have found it necessary
to develop a standard way of coding, or a routine that I force myself to
follow. I learned C by myself out of a collection of now outdated books, and
have seen the return statement used in both ways. I personally use:
   return (2+2);
  The reason for this is due to the nature of C. I could create, and have, a
return statement that runs off the page due to the way the return value is
being acquired. I have found that by putting parenthesis around the statement
I have made it mor readable for me.  Being also fluent in Lisp, I understand
the disadvantage of parenthesis, but nevertheless it should be used in order
to maintain consistency with the programmers style.
  As to the students lack of understanding concerning the parenthesis, this
is due to their not reading the text book, or listening to the lecture
carefully, but not to their use of parenthesis.  I have seen many a C text
book, but never have I seen one that did not explain what difference between
a function and a statement is, and that return was a statement.

-Of course this is just one mans opinion.

    David T. Buksbaum
    
--
+---------------------------------------------------------+
= David T. Buksbaum *      *** NOTICE ***                 =
= HAND 225A         *                                     =
= Stony Brook, Ny   *    UNDER CONSTRUCTION               =



More information about the Comp.lang.c mailing list