bug-gnustep
[Top][All Lists]
Advanced

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

[OT] styles.


From: Pascal Bourguignon
Subject: [OT] styles.
Date: Sat, 8 Dec 2001 18:15:56 +0100 (CET)

Nicola Pero <n.pero@mi.flashnet.it> wrote:
> 
> > My point  is that by always writting  the brace on the  same line than
> > the while,  if, else, for, etc,  and without spaces  between the right
> > parenthesis,  the intruduction  of an  unwanted semi-colon  would just
> > jump in one's face and such an error would not pass unnoticed.
> > 
> >      while(condition);{some-code-here}
> 
> but richard/gnu has a similar convention - he always puts immediately a
> newline after the ')' of the condition, because he always puts an opening
> '{' on the next line, as in
> 
>  while (condition)
>    {
>       do_something ();
>    }
> 
> so a ';' on the same line of the while would just jump in his face and
> never pass unnoticed:
> 
>  while (condition);
>    {
>      do_something ();
>    }
> 
> is obviously immediately wrong, because *nothing* must follow the
> (condition) on that line according to this coding style, so the ';' is
> wrong there.


      while(condition); 
      next-statement;

is an accepted form in common C styles. 

      while(condition);
        {
          statements;
        }

is not  accepted granted, but it's  more difficult to  spot because it
involves two  lines, and  more over  the first one  is legal  in their
style-book. What happens, is that they  may see only the first line at
the bottom of the window and won't be able to spot the problem.


 
> I think it is easier to detect the unwanted ';' in his style than in your
> style, because in your style if you do the typo you write
> 
>  while(condition);{
>     do_something();
>  }
> 
> then the ';' is buried between the ')' and the '{' and so it is more
> difficult to spot.

Of course,  all depends on what  you're looking for. It's  a matter of
eye scanner.   Since );{  is illegal  for me, it  never happens  in my
sources, and I would notice it at once in a 132x64 listing on a 150dpi
screen.


 
> On the other hand, richard - when tired - is more likely to type a ';'
> after the while (condition), since the while is on its own line alone, and
> looks like it were a single command - which is normally followed by a ';'
> _ well while I prefer the style richard is describing because it's easier
> to read (for me), I don't think it makes much difference either way - it's
> more important to consistently use a single style everywhere in a big
> project - so in gnustep we stick to the one which was chosen (and which is
> commonly used in other big projects as well) - we are using the GNU style
> everywhere.

Well, I dream  of an intelligent pretty-printer that  would be able to
do correctly more  profund but semantically equivalent transformations
on the  sources. With such a tool,  I guess that people  could be more
flexible with styles, and be more willing to ammend their style, or it
could be used  to checkout the sources in the  different style of each
programmer.

I did  not elabored  my own  programming style at  the first  minute I
approached a computer. It evolved  during years and still do. And when
I  did  big  changes  to  my   style  book,  I  just  ran  scripts  to
automatically update my sources, so it never was such a big deal.

 
> As a side note, I think the coding style helps with preventing silly
> syntaxtical errors, but the compiler helps more :-)

Not C compilers. 



> both of you agree (and I do as well) that "while (condition)" followed by
> a ';' not enclosed by brackets - '{', '}' - is bad coding style - so I
> suppose both of you would be happy if the compiler would emit a warning
> upon finding "while (condition)" followed by ';' without the brackets
> around the ';'.  That would detect the typo whatever style you use -
> wherever you put your newlines and your spaces.

That  would imply  changing the  syntax of  C. Then  why not  just use
another  language  like  MODULA-3?  (Never  mind,  it's  a  rhetorical
question).




-- 
__Pascal_Bourguignon__              (o_ Software patents are endangering
()  ASCII ribbon against html email //\ the computer industry all around
/\  and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100  2001:my($f)=`fortune`;  http://petition.eurolinux.org/

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++  UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]