In article <45360002@hpcuhe.cup.hp.com> defaria@hpcuhe.cup.hp.com (Andy DeFaria) writes:
>That's because you view it as an open ({) and corresponding close (}).
Accurate enough.
>To me,
>such statements, while they require a close, should not require an open.
I disagree. Symmetry is desirable in a language. I detested PL/1 for its
requiring a ';' at the end of *every* statement - it implied that the
statement "else i = 3;" was a valid standalone statement.
>In
>other words the assumption should be that I always have a compound statement
>and must tell the compiler when it's done.
Again, I disagree. Since a compaund statement is lexically identical
to a single statement, they should have the same form.
>C required that I also specify an
>open but I see no reason to devote a full line to it! I detest:
>
> if (condition)
> statement;
> statement;
I don't quite understance why this bothers you.
>or
> if (condition) statement;
> statement;
>
>It's just too easy to misread the fact that C will only execute the first
>statement if condition is true.
This I agree with - it's far too easy to miss the statement on the end of the
line and assume the second one is controlled by the condition.
>I would code:
>
> if (condition) {
> statement;
> } /* if */
>
> statement;
>
>Note I label my terminating close (}). Now think about it. When eyeballing
>the above code and reading the if statement: Do you really care where it has
>opened or when it has closed? To me the open is inconsequential: Of course it
>starts but where does it end?
I think that this is why I prefer the braces on separate lines - to make their
associations clear. I dislike a comment that is placed for syntactic reference.I prefer comments be reserved for semantic clarification. In some of the
code I've seen, there would be a forest of /* if */'s hiding the desired
semantic information.
--
Pete Hardie: phardie@nastar (voice) (404) 497-0101