Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c code "beautifier"

Author: Tord Romstad

Date: 07:28:20 12/03/03

Go up one level in this thread


On December 03, 2003 at 08:31:43, Francesco Di Tolla wrote:

>
>>I've always wondered why people like to have lines containing only a
>>brace and nothing else.
>
>because it is ANSI standard. And it is ANSI standard becasue it is easy to read

I wasn't aware that there was an ANSI standard for how the code should
be formatted, but of course I'll believe you if you say so.  :-)

As has been pointed out elsewhere, what is easy to read is to a large
extent a matter of taste.  Personally, I find the information density
in the standard style too low to be easily readable.  A line containing
only a brace gives me precisely zero information, because I always read
the block structure by indentation.

>it is very important to be able to "read" which level of brace you're closing so
>the closing brace is always on a new line.

Why is it very important?  I cannot remember that I have *ever* needed
or wanted to know which level of brace one particular closing brace is
closing when I read code.

>Your piece of code is fine but if the function is say hundred lines (or even a
>1000 lines) long, then reading:
>
>...
>   if(...) {
>     .
>     .
>     .
>        .
>           .
>             100 lines
>                   somestatement;}
>
>how do you know what is that brace closing?

When I type the code:  The editor tells me.  When I read the code:  By
looking at the indentation.

>Many editors have a matching brace utility but the indentation helps to
>"read" anyway.

I would never even consider using an editor which did not support paren
matching, automatic indentation and navigating and editing the code by
expressions rather than by lines and characters.  An editor without
such facilities is entirely unsuitable for any kind of programming,
IMHO.

Regarding Anthony's comment that my coding style would have driven his
boss nuts:  I hope I'll never have a job where my boss wants to read my
code, and also that I'll never have a job where I need to code in any
other language than Common Lisp.  :-)

Tord




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.