Unnecessary parenthesis

T. William Wells bill at proxftl.UUCP
Wed Jul 13 13:25:48 AEST 1988


In article <8108 at elsie.UUCP>, ado at elsie.UUCP (Arthur David Olson) writes:
> I leave out the parentheses in a
>       return whatever;
> statement; this ensures that if I mistakenly write
>       retunr whatever;
> I'll get a warning at compile time--along with a line number--rather than
> an "Undefined: _retunr" error at link time (with no indication of where the
> error is) as would be true if I wrote
>       retunr(whatever);
> (which the compiler would take to be a function call.)

This is the first non-esthetic reason I've seen for not putting
in the parentheses; I'd note that it does not always work,
consider: retunr (a+b)*c;. Oh, well, nobody said programming was
going to be trivial...

Just to add some data to the discussion, here is what we do.

    o No function call has a space after the function descriptor.

    o Every keyword except sizeof is always followed by a space,
      newline, or semicolon.

    o Sizeof is always formatted as if it were a function call.
      Actually, we code no space after the sizeof because it is
      a unary operator and we parenthesize for uniformity; this
      makes it look like a function call.

    o For purely Hysterical Raisons we always use parentheses
      around the expression.  I think we'd change except for
      inertia and the pain of reformatting all the code of a new
      version of a product.

My own opinion on the use of parentheses is that almost any
consistent style is better than no style at all.  The
differences between most styles is a matter of esthetics; one
may choose almost any style one pleases and be "right".



More information about the Comp.lang.c mailing list