Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linux-dvb] Re: cinergyT2: which kernel/usb module to use?



Johannes Stezenbach wrote:
Klaus Schmidinger wrote:

Well, the placement of the closing braces is apparently a major
philosophical issue ;-)

Maybe it's more a typographic issue ;-)

Anyway, the point is that it is different than what I am *used to*.
Even worse, based on those hardwired assumptions in the back of my head
about how source code is usually layed out, your placement of closing
braces is actively misleading me :-(
Well, guess what: the same applies to me when I read the DVB driver
source code ;-)

As I said, it's not just a "typographic issue" - it _is_ a philosophical
issue. The structure is

  if (condition)
     statement;

I guess we all agree that the 'statement' shall be indented (sure
enough there are different ideas as to how far it shall be indented,
but let's forget about that for the moment). Writing

   if (condition)
   statement;

would certainly not be well readable. Now, what if the 'statement'
happens to be not just a single statement, but a compound statement?
Well, I'd say it should still be indented. So, what is a compound
statement? It is a sequence of statements, enclosed in braces. And does
the closing brace belong to the compound statement? Sure enough it does!
So, if we indent the compound statement, why would we _not_ indent
it's closing brace?

Maybe all this becomes even clearer if we look at a Pascal code example:

  if (condition) then begin
     statement;
     statement;
     end
  else if (condition) then begin
     statement;
     statement;
     end
  else begin
     statement;
     statement;
     end;

To me this looks a lot better and easier to comprehend than

  if (condition) then begin
     statement;
     statement;
  end
  else if (condition) then begin
     statement;
     statement;
  end
  else begin
     statement;
     statement;
  end;

Here there is just some "noise" obfuscating the important information.


I guess everybody has their own ideas about how code should be formatted.
There's also something called the "baby duck effect" involved here (the
first thing they see is the right thing). I've been writing code using
my way of formatting for more that twenty years, and I'm not going to
change the way I format it - simply because it's, of course, the right
way ;-)

As I said, it _is_ philosophical... ;-)

Klaus




Home | Main Index | Thread Index