This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Coding style question


On Thu, Sep 26, 2002 at 05:18:05PM +1000, Andreas Bauer wrote:
> It was being pointed out to me that you might prefer in patches the
> style (A)
> 
>   bool
>   function (args)
>   {
>     /* ... */
>     return (<condition>);
>   }
> 
> over (B)
> 
>   bool
>   function (args)
>   {
>     /* ... */
>     if (<condition>)
>       return true;
>     else
>       return false;
>   }

I don't think form B is useful.  Depending on how complex the
condition is, I might like to have it broken up into

	if (cond1)
	  return false;
	if (cond2)
	  return true;
	if (cond3)
	  return false;
	return true;

But you should not do this when simply moving code around.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]