Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Indent style

Name: Anonymous 2010-09-01 6:41

Don't you hate it when people indent their code like this?

template
<class C>
C*
v_DoSomething (    C a,
        C b,
        C c   )
{
    C* _ptrResult = &a;
    if ( a >= b )
    {
        return ( _ptrResult );
    }
    else
    {
        if ( b >= c )
        {
            return &c;
        }
        else
        {
            return _ptrResult;
        }
    }
}

Name: Anonymous 2010-09-01 6:44

Don't you hate it when people neglect to use CODE tags?

Name: Anonymous 2010-09-01 7:11

Looks readable to me, but I wouldn't use all those blocks with single statements, looks way too verbose, in general, that code is way too verbose. Also you forgot your code tags.

Name: Anonymous 2010-09-01 7:35

*** Warning: Sepples "programmer" detected. Deploy ENTERPRISE BEST PRACTISES and await further instruction.

Name: Anonymous 2010-09-01 8:02

I find GNU style very unfufilling


int main(void)
  {
    int i;
    for ( i = 0 ; i < 5 ; i++ )
      {
        printf("%d\n", i);
      }
  }


Although it makes sense to me, since if you don't have a block of code, that's where the single statement will be indented to

Name: Anonymous 2010-09-01 9:56

I'd hate to see this with multiple else if blocks.

Name: Anonymous 2010-09-01 13:09


#include <stdio.h>

int
main
(
    void
)
{
    int i;
    for
    (
        i = 0;
        i < 5;
        ++i
    )
    {
        if (i == 0)
        {
            puts("0");
        }
        else if (i == 1)
        {
            puts("1");
        }
        else if (i == 2)
        {
            puts("2");
        }
        else if (i == 3)
        {
            puts("3");
        }
        else if (i == 4)
        {
            puts("4");
        }
        else
        {
            puts("5");
        }
    }
    return 0;
}

Name: Anonymous 2010-09-01 15:20

>>1
This is a decent style.  Readable.
There are a few unnecessary newlines, though.


template <class C> C* v_DoSomething (C a, C b, C c)
{
    C* _ptrResult = &a;

    if (a >= b)
    {
        return (_ptrResult);
    }
    else
    {
        if (b >= c)
        {
            return &c;
        }
        else
        {
            return _ptrResult;
        }
    }
}

Name: Anonymous 2010-09-01 15:22

>>8
"Unnecessary" was the wrong word...  All newlines in C++ are unnecessary.  "Superfluous" is better.

Name: Anonymous 2010-09-01 15:57

>>9
They mean the exact same thing.

Name: Anonymous 2010-09-02 2:08

>>10
Respect my connotations!

Name: Anonymous 2010-09-02 8:32

This style is the best, it compiles fastest and saves disk space:


template<class C> C*v_DoSomething(C a,C b,C c)
{
C* _ptrResult = &a;
if(a>=b){return (_ptrResult);}
else{
if(b>=c){return &c;}else{return _ptrResult;}
}
}

Name: Anonymous 2010-09-05 1:18


template<class C> C*v_DoSomething(C a,C b,C c)
{
C* _ptrResult = &a; return ((a>=b)?_ptrResult:((b>=c)?&c:_ptrResult))
}

-O3-ized for you

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List