the inevitable C formatting/brace style flamewar

Norbert Thiebaud nthiebaud at gmail.com
Thu Aug 16 10:57:06 PDT 2012


On Thu, Aug 16, 2012 at 12:07 PM, Michael Stahl <mstahl at redhat.com> wrote:
> so this:
>
>>     if( pCT->pInsBox )
>>     {
>>         pCT->pInsBox->GetTabLines().push_back( pNewLine );
>>     }
>>     else
>>     {
>>         pCT->pTblNd->GetTable().GetTabLines().push_back( pNewLine );
>>     }
>
> could be much shorter, with only 20% brace line overhead:
>
>>     if( pCT->pInsBox ) {
>>         pCT->pInsBox->GetTabLines().push_back( pNewLine );
>>     } else {
>>         pCT->pTblNd->GetTable().GetTabLines().push_back( pNewLine );
>>     }
>

and
>>     if( pCT->pInsBox ) { pCT->pInsBox->GetTabLines().push_back( pNewLine ); } else { pCT->pTblNd->GetTable().GetTabLines().push_back( pNewLine );}

is 80% shorter.. what's the point ?

The braces lines are not 'overhead', there are visual-aid...  chasing
'{' at the end of lines is cumbersome and slow, and the irregularity
of the use of braces at all make the endeavor even more cumbersome and
error prone.

you said it yourself:
"rationale: in this case it's good to visually separate the condition
from the compound statement, e.g. this is a PITA to read: [...]

so you agree that " it's good to visually separate the condition
from the compound statement,"

which version best achieve that goodness:
>>     if( pCT->pInsBox )
>>     {
>>         pCT->pInsBox->GetTabLines().push_back( pNewLine );
>>     }
>>     else
>>     {
>>         pCT->pTblNd->GetTable().GetTabLines().push_back( pNewLine );
>>     }

or

>>     if( pCT->pInsBox ) {
>>         pCT->pInsBox->GetTabLines().push_back( pNewLine );
>>     } else {
>>         pCT->pTblNd->GetTable().GetTabLines().push_back( pNewLine );
>>     }

( it is a rhetorical question)

furthermore, how many people still use 80x24 terminal ? iow, why
putting a premium on vspace at the expense of readability ?

Norbert


More information about the LibreOffice mailing list