Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c code "beautifier"

Author: Anthony Cozzie

Date: 06:22:10 12/03/03

Go up one level in this thread


On December 03, 2003 at 03:55:18, Daniel Clausen wrote:

>On December 02, 2003 at 18:54:50, Pat King wrote:
>
>>On December 02, 2003 at 13:38:06, Georg v. Zimmermann wrote:
>>
>>
>>>Now I need some source code beautifier which can produce smth like (my prefered
>>>style):
>>>
>>>if (ifClauseExample)
>>>{
>>>      for (forExample = 1; ;)
>>>      {
>>>            if (oneLineIf)
>>>                  shouldLookLikeThis();
>>>      }
>>>}
>>>
>>>and which I can configure in reasonable time without having to read 500
>>>man-pages.
>>>
>>>Help very much appreciated,
>>>
>>>Georg
>>
>>I use Emacs, which mangles the above as follows:
>>
>>if (ifClauseExample)
>>{
>>  for (forExample = 1; ;)
>>    {
>>      if (oneLineIf)
>>	shouldLookLikeThis();
>>    }
>>}
>>
>>which appears pretty close to perfect. Emacs does offer several other styles,
>>and the ability to roll your own, if you're willing to delve into the info
>>files.
>>
>>Pat
>
>Any special reason why the brackets are lined up with the "if" statement but not
>with the "for" statement?
>
>Sargon

emacs assumes K&R brackets by default, and makes bad assumptions.  TAB under an
if/for will bring you 2 spaces past the if/for.  Dunno how he got the first one
to work :)

Personally I'm with Tord on this one.  My goal is to get as much code as
possible onto one screen.  It's like free RAM :)

In Zappa there are even sections like

if() { a; b; }
else { c; d; }

:)

To me this can be quite readable if you do it right (only for very short
statements a/b/c/d of course).

anthony



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.