Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: [Review] Re: advdomestic.c cleanup II. (PR#1157)
Home

[Freeciv-Dev] Re: [Review] Re: advdomestic.c cleanup II. (PR#1157)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [Review] Re: advdomestic.c cleanup II. (PR#1157)
From: Jason Short <vze2zq63@xxxxxxxxxxx>
Date: Tue, 01 Jan 2002 06:26:47 -0500
Reply-to: jdorje@xxxxxxxxxxxx

Gregory Berkolaiko wrote:

--- "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx> wrote: [..]

if (doodle && beeble) {
blah = trrrrr
       + frrrr;
}

and NOT

if (doodle && beeble) { blah = trrrrr + frrrr;
}

I don't know if this was universally agreed on or agreed on by lack of response, but yes, yes, YES!
 indent -kr2 -bbo ...  # should be updated in the main FAQ pages.

I think lack of response, but I prefer to think that it was taken for
granted by most of the people thus not discussed much ;)

I concur.


To Petr:  What's so good about it?  I really don't know (probably Ross
knows better) any unbeatable reasons.  I'm just used to it and I think
it's the standard way.

Some good ones have already been mentioned.  Also, for code like

  x = a
      + b
      - c
      + d;

it is much better to have the operators in front; not only does this draw attention to them, but it also associates them correctly with there targets since the "-" is more closely associated with the c than the b (IIRC Gaute pointed this out in the previous discussion). Compare this to

  x = a +
      b -
      c +
      d;

and it should be clear.

But there are some situations in which I prefer trailing operators, usually in simple expressions to get the operands to line up. Consider

  if (write_data_to_socket(fd, data1) < 0 ||
      write_data_to_socket(fd, data2) < 0 ||
      write_data_to_socket(fd, data3) < 0)
    handle_error();

here using trailing operands lets you line up the operands (the function calls) so that the differences are more visible. So, I think it's still a matter of preference in some cases.

BTW, in school I was tought to put the operator
on both lines, like

y = 4x^3 + 5x^4 + 6x^5 +
    + 7x^6 + 8x^7 + 9x^8

That's craziness!

jason



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