Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7369) [RFC] Coding style
Home

[Freeciv-Dev] Re: (PR#7369) [RFC] Coding style

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: i-freeciv-lists@xxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#7369) [RFC] Coding style
From: "Mike Kaufman" <kaufman@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 2 Feb 2004 06:27:11 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=7369 >

On Mon, Feb 02, 2004 at 02:56:38AM -0800, Raimar Falke wrote:
> 
> > On further reflection I agree with Per: rather than single versus
> > multi-line expressions it should be variables versus expressions.
> 
> Here you step into a mine field. First a variable is also an
> expression (in the language definition). But I understand you. So what
> expressions and operators are allowed? What about
>   return a->b[c].d->e[f].g.h;
>   return masked == to_test_for;
>   return TEST_BIT(pcity->city_options, option);
>   return unit_buy_gold_cost(to, unit_disband_shields(from));

I do _not_ support the mandate of parentheses on any type of return
statements.  I don't like parentheses on single expression return
statements because it confuses the return statement for a function call. 
I will occasionally code parentheses around complicated expressions. So a
codification of my preference would look like:

return (p);            /* not allowed */
return (p && q && !r); /* optional based on readability of code */

> 
> A related issue is:
>   foo += bar / 2;
> vs
>   foo += (bar / 2);

codifying this is silly.

-mike




[Prev in Thread] Current Thread [Next in Thread]