|
![](/i/fill.gif) |
"Jon A. Cruz" <jon### [at] geocities com> writes:
>
> Could I bug you to try to always use braces, even for single line
> bodies?
>
> {
> if(Ch=='\n') {
> ungetc ('\r', (FILE *) File->Data);
> }
> ungetc (Ch, (FILE *) File->Data);
> }
>
> As opposed to some things that are just a matter of style ( e.g. where
> you decide to place them), always using braces even for single line
> bodies is a good idea that helps prevent problems. Sometimes it's
> possible to write logic incorrectly and miss it due to misleading
> indention, but braces would catch that.
That's why I let EMACS do the indentation do for me. This results in
a correct indentation in the sense that it reflects the assignment of
lines to loops and if statements.
If you are used to this code styling (which is the case for me), you
won't forget the braces when you add a second line. If I'm urged
to make the braces, I would have added them like this:
{
if(Ch=='\n')
{ ungetc ('\r', (FILE *) File->Data); }
ungetc (Ch, (FILE *) File->Data);
}
It is more compact and therefore clearer in my opinion.
> Also, there are times when what
> you thought was a simple function might actually change to be a
> multi-line macro... and if so, BOOM!
Because of this, I add braces to my multi-line macros. (In C++ I don't
use multi-line macros at all.)
Thomas
--
http://thomas.willhalm.de/ (includes pgp key)
Post a reply to this message
|
![](/i/fill.gif) |