delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/04/06/15:08:37

From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Bracketing: A Matter of Style
Date: 6 Apr 2000 12:02:06 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 48
Message-ID: <8chubu$bep$1@nets3.rz.RWTH-Aachen.DE>
References: <38EBD03D DOT 895D1680 AT mindspring DOT com>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 955022526 11737 137.226.32.75 (6 Apr 2000 12:02:06 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 6 Apr 2000 12:02:06 GMT
Originator: broeker@
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I'll try not to put oil into what may easily become the usual coding
style flame war, but some of the positions put forth here are
objectively wrong, so let me comment on them.

james archer <snowphoton AT mindspring DOT com> wrote:

[...]
> I realize that most coders are almost religiously against this
> bracketing system, and cling instead to the trendier style exemplified
> thusly:

> int main(void) {
>     printf("Hello, World!");
>     return 0;
>     }

No, this is *not* an anywhere near frequently seen code layout style.
Putting the opening brace on the line of the opening statement is
frequently done with blocks _inside_ a function, sure. But I don't
think I've ever seen anyone do it for the *function's* outer braces,
themselves. Functions are almost always layed out this way:

int main(void)
{
   /* stuff here */
}

or, by people using certain tools, sometimes, you'll see:

int
main(void)
{
   /* stuff here*/
}

Finally, let me tell you my personal reason for putting the opening
brace on the line of a for', 'if' or similar statement is that a brace
in a line of its own costs a full line of vertical screen space. Given
that the screen is considerably less high than it is wide, I consider
that a waste of valuable 'real estate'. I may have been biased by
starting to code in PC 80x25 text screens, where this effect is even
worse than on other platforms.  For somewhat complicated code
structures, it can make a big difference whether the whole block fits
into one screenful of text or not, and braces on their own lines make
that hard to achieve, at times.
-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019