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: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7369) [RFC] Coding style
From: "Raimar Falke" <i-freeciv-lists@xxxxxxxxxxxxx>
Date: Mon, 2 Feb 2004 02:56:38 -0800
Reply-to: rt@xxxxxxxxxxx

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

On Mon, Feb 02, 2004 at 01:39:00AM -0800, Jason Short wrote:
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7369 >
> 
> >> Note that the first is formatted "properly" according to the style
> >> guide
> >
> > I searched the style guide before I posted this one and found
> > nothing. While it contains examples of the first one it doesn't state
> > anything about what should be used and what not.
> 
> I mean the intendation is correct.  AFAIK there is no rule about
> indentation of general expressions.

The original question was about parentheses or not.

> Like
> 
>   some_really_long_variabe =
>     some_really_long_expression();
> 
> versus
> 
>   some_really_long_variable
>     = some_really_long_expression();
> 
> versus
> 
>   some_really_long_variable
>   \t= some_really_long_expression();
> 
> (\t == a tab)
> 
> Though perhaps I am wrong.  (I prefer form #2, though this may vary
> depending on the lengths of variable and expression.)

It is more complex. At least I think indent(1) uses a more complex
algorithm. These are examples which indent(1) produces.

adlklkadlkasdadssdaklasjdlkjasdlkjsadkjlkkjlkj =
    lkasjdlkajsdjk lkjaslkdadkasdasasdaddj;

adlklk =
    adlkasdadssdaklasjdlkjasdlkjsadkjlkkjlkjlkasjdlkajsdjklkjaslkdadkadada;

> >> (and most editors will give you this).  AFAIK the style guide does not
> >> specify a formatting for the second (and editors may be inconsistent).
> >
> >> So my preference would be: no-parenthesis for single-line,
> >> parenthesis for multi-line.
> >
> > While this is also my personal preference it is inconsistent.
> 
> How is it inconsistent?  It applies just fine in either case.

Ok. It is however more complex than a "always use ...".

> 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));
?

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

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
  One nuclear bomb can ruin your whole day.




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