Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c code "beautifier"

Author: Francesco Di Tolla

Date: 05:39:50 12/04/03

Go up one level in this thread


>>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.

sometimes you're forced from the enviroment: to me it happens often to have to
use vi which blinks but if your block is big enough you don't get the feeling of
where the matching brace is. In emacs and many windows editors you get a
different message, bu you should't assume people are yousing the same editor you
do.

>When I read the code:  By looking at the indentation.

No you can't. Or you can count the spaces with an eye blick?

fun()
{
  if(){
    .
    .
    if(){
      .
      .
      while(){
        last stat;}}}}

here the fact you have an extra/missing brace is less obvious then in the next
case, cause you have to count the spaces in front of "last" and this is only a
level 3 indent!

fun()
{
  if(){
    .
    .
    if(){
      .
      .
      while(){
        last stat;
      }
    }
  }
}
here it is easy: you just have a ladder of braces evenly spaced by you default
indent.

>
>>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.

cause you do programming for yourself, if you do it four your job often you use
the enviroment someody else has set up.

>An editor without such facilities is entirely unsuitable for any
>kind of programming,IMHO.

I agree but sometimes you do quick fixes, say from the site of you customer and
you telnet back home and baraely manage to open vi on your files...

>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.  :-)

In my company we used to have strict standards on coding, people are not really
always following them, but a "bad notation" like closing multiple braces on the
same line is something nobody ever does.

regards
Franz




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.