Unnecessary parenthesis

Dave Decot decot at hpisod2.HP.COM
Thu Jul 7 12:31:16 AEST 1988


> >	return 0;		/* intuitive */
> 
> To a FORTRAN programmer.

And to a C programmer.  Return is a statement that modifies the default
flow of control, such as:

     goto label;		/* NOT goto(label); */
     break;			/* NOT break();     */
     continue;			/* NOT continue();  */

Return is not a function call, and it shouldn't look like one.

> >	return(0);	/* one wonders why the () are there */
> 
> 1) Because it looks consistent.

With what?  Why do you want to make it easier to confuse function calls
with statements that don't come back?

> 2) It's intuitive to a converted Pascal or PL/I programmer.

Why?  Ordinary Pascal has no return statement.

> 3) The programmer has gotten used to putting parentheses around just about
>    everything.

That may be true in your case, but it's a bug in the language design.
Parentheses are overloaded for all of the following distinct purposes:

    function calls
    if, while, and do-while statements
    casts
    type construction (used both to indicate functions and for grouping)
    function declarations
    evaluation order grouping

I see no reason to add further confusion by making flow control look like
a function call.  I use "return e;" because it's less cluttered and more
distinct.

Dave Decot
hpda!decot



More information about the Comp.lang.c mailing list