User: Password:
Subscribe / Log in / New account

Omitting extra braces is a boon

Omitting extra braces is a boon

Posted Jun 11, 2008 19:11 UTC (Wed) by jengelh (subscriber, #33263)
In reply to: Omitting extra braces is a boon by bronson
Parent article: Implications of pure and constant functions

That's not the point.

(Log in to post comments)

Omitting extra braces is a boon

Posted Jun 12, 2008 0:08 UTC (Thu) by dododge (subscriber, #2870) [Link]

If your point is that people write horrible over-long functions, no argument there. The C89 rules certainly didn't stop them doing it, though, and frankly if I'm dealing with some 1000-line monstrosity of a function I'd rather be able to put the declarations on the same screen as the code using them, so that 1) I don't have to keep skipping back and forth to remember the types, and 2) I don't have to worry about what the 200 lines of code between the start of the function and the spot I'm looking at might have done with those variables.

But the main point, as already stated, is that from a practical standpoint you can't easily make your local variables const unless you either use mixed declarations or futz about with bracing and deep nesting. As someone who marks as much const as I can, and tries to limit scope as much as possible, I do make heavy use of mixed declarations and it's one of the C99 features that would be hardest to give up.

Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds