[haiku-commits] Re: r33923 - haiku/trunk/src/apps/deskcalc

  • From: "Ingo Weinhold" <ingo_weinhold@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 06 Nov 2009 18:54:06 +0100

-------- Original-Nachricht --------
> Datum: Fri, 06 Nov 2009 18:34:16 +0000
> Von: "Alexandre Deckner" <alex@xxxxxxxxxxxx>

> Concerning line braking and tabs, does function call parenthesis always
> count as an expression level? Would the following examples be correct?
> (using spaces for tabs intentionally for proper render in mail clients)
>  
> if (archive->FindData("rgbBaseColor", B_RGB_COLOR_TYPE,
>         (const void**)&color, &size) < B_OK
>     || size != sizeof(rgb_color)) {
>     fBaseColor = (rgb_color){ 128, 128, 128, 255 };
>     puts("Missing rgbBaseColor from CalcView archive!\n");
> } else {
>     fBaseColor = *color;
> }
> 
> // Same but simpler condition
> 
> if (message->FindData("text/plain", B_MIME_TYPE,
>         (const void**)&text, &numBytes) == B_OK) {
>     BString temp;
>     temp.Append(text, numBytes);
>     fExpressionTextView->Insert(temp.String());
> }

That's the way I'd indent those, too.

> // In assignment
> 
> ret = archive->AddData("rgbDisplay", B_RGB_COLOR_TYPE,
>         &fExpressionBGColor, sizeof(rgb_color));
>               
>       
> // Parenthesis in simple assignment
> 
> lightness = (fExpressionBGColor.red
>         + fExpressionBGColor.green + fExpressionBGColor.blue) / 3;

In both cases I would only indent one level, since unlike in an if statement 
things end with the second line and the additional indentation level doesn't 
really add to the readability. To make the subexpressions more obvious in the 
second case I would indent two levels, if the expression continued on the next 
line, though:

lightness = (fExpressionBGColor.red
        + fExpressionBGColor.green + fExpressionBGColor.blue)
    / 3;

CU, Ingo

Other related posts: