[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSAttributedString (Foundation) bug
From: |
Nicola Pero |
Subject: |
Re: NSAttributedString (Foundation) bug |
Date: |
Sat, 8 Dec 2001 14:51:09 +0000 (GMT) |
> 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.
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.
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.
As a side note, I think the coding style helps with preventing silly
syntaxtical errors, but the compiler helps more :-)
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.