Omitting extra braces is a boon
Omitting extra braces is a boon
Posted Jun 11, 2008 18:43 UTC (Wed) by bronson (subscriber, #4806)In reply to: Omitting extra braces is a boon by jengelh
Parent article: Implications of pure and constant functions
Doesn't your editor or IDE color the variable declarations?
      Posted Jun 11, 2008 19:11 UTC (Wed)
                               by jengelh (guest, #33263)
                              [Link] (1 responses)
       
     
    
      Posted Jun 12, 2008 0:08 UTC (Thu)
                               by dododge (guest, #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.
 
     
    Omitting extra braces is a boon
      
That's not the point.
Omitting extra braces is a boon
      
 
           