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

How do you indent?

Name: Anonymous 2009-07-29 12:23

What is your preferred style of code indentation? I personally tend to use the GNU style indent.


static char *
concat (char *s1, char *s2)
{
    while (x == y)
      {
        something ();
        somethingelse ();
      }
    finalthing ();
}

Name: Anonymous 2009-07-29 12:25

ITT we adopt FV style.

Name: Anonymous 2009-07-29 12:28

>>1
I usually use ``Java'' style. I don't mind other styles, though GNU style is fucking illegible and should be purged.

Name: Anonymous 2009-07-29 12:33

FIOC style, bro.

static char *
concat (char *s1, char *s2) {
   while (x == y) {
      something ();
      somethingelse (); }
   finalthing (); }

Name: Anonymous 2009-07-29 12:37

GNU is acceptable if it's using either tabs or spaces, but not both.
Allman is acceptable.
K&R is king.

Name: Anonymous 2009-07-29 12:45

>>-
Please observe official /prog/ style from now on.  Thank you.

static char *concat
                   (
 char *s1, char *s2
)
                   {
 while
        (
  x == y
 )
                  {
  something();
  somethingelse();
 }
 finalthing();
}

Name: Anonymous 2009-07-29 12:45

(modified?) Allman style, two spaces, without omitting braces even in single statements, and the three-line else. Yeah, call it waste of space, I don't give a flying Philadelphia fuck.


void frozen(int n)
{
  int i, j;

  for(i = 0; i < n; i++)
    for(j = 0; j < n; j++)
    {
      if(i==j)
      {
        foo(i, j);
      }
      else
      {
        bar(i, j);
      }
    }
}

Name: Anonymous 2009-07-29 12:50

>>7
without omitting braces even in single statements
But you will omit them if that statement already spans multiple lines?

Name: Anonymous 2009-07-29 12:59

>>8
I have never faced such a problem, and additionally, I don't see how is that relevant.

Name: Anonymous 2009-07-29 13:00

void frozen(int n)
{
  int i,j;

  for(i = 0;
      i < n;
      i++)
    for(j = 0;
        j < n;
        j++)
    {
      if(i==j)
      {
        foo(i,
            j);
      }
      else
      {
        bar(i,
            j);
      }
    }
}

Name: Anonymous 2009-07-29 13:00

>>10 Forgot my code tags, but you get the idea (arguments stacked vertically)

Name: Anonymous 2009-07-29 13:01

>>9
Are you blind?  Look at you're goddamn code.

Name: Anonymous 2009-07-29 13:02

>>12
* your
IHBT

Name: Anonymous 2009-07-29 13:04

Oh, and in real code one-statement ifs are scarce, so it doesn't look that bad.

Name: Anonymous 2009-07-29 13:46

>>14
YOU MEAN A TERNARY OPERATOR?:

Name: Anonymous 2009-07-29 13:59

Oh, and in real code one-statement ifs are scarce
Why?

Name: Anonymous 2009-07-29 14:13

>>16
What kind of question is that? When I write code, I rarely use such ifs, most often replacing them with ?:. It's not a ``why'' question, damn it.

Name: Anonymous 2009-07-29 14:15

>>17
YHBT

Name: Anonymous 2009-07-29 14:28

>>17
IT'S A TERNARY OPERATOR.

Name: Anonymous 2009-07-29 14:46

>>19
Thirdinary

Name: Anonymous 2009-07-29 14:51

I was looking at styles earlier, and I don't see why there are no common/official styles that appeal to me. I was about to say that I use BSD style, but then I noticed that it has Java-style else statements.

>>3,17
Fuck you and fuck your K&R faggot quotes.

void funct(int *yumyums, const std::vector<int> &results) {
    if (yumyums == 0)
        return;

    int result = 0;

    for (int i = *yumyums; i > 0; i--) {
        result = i * i;
        result = i ^ result ^ 0x55;
        if (result > 0x50000000) {
            results.push_back(result);
        }
        else {
            i++;
        }
    }
}

Name: Anonymous 2009-07-29 14:52

>>19
Trinary.

Name: Anonymous 2009-07-29 14:56

>>21
Aaaaaaand the purpose of my insanely useless function shifted a few times as I was writing it, that const should not be there.

Name: Anonymous 2009-07-29 15:00

int foo(int* bar) {
    if((*bar) == 0) {
        return -1;
    }

    return 2*(*bar);
}


this

Name: Anonymous 2009-07-29 15:02

it doesn't matter as long as it's readable.

Name: Anonymous 2009-07-29 15:07

>>21
>>23
Let me fix that for you.


void funct(int *yumyums,std::vector<int> &results){
    if (!yumyums)
        return;
    int result=0;
    for (int i=*yumyums;i>0;i--){
        result=i*i;
        result=i^result^0x55;
        if (result>0x50000000)
            results.push_back(result);
        else
            i++;
    }
}

Name: Anonymous 2009-07-29 15:27

>>26
Do those that use See/Sepples actually write code like that in production environments? If so, you're a fucking liability to any company that has the misfortune of hiring you.

Name: Anonymous 2009-07-29 15:35

>>27
No. Those that code in any language within a group follow that group's style guidelines regardless of their personal preferences.
Of course, you'd know this already if you had ever programmed for a living.

Name: Anonymous 2009-07-29 15:39

>>28
I don't think the thread's prompt means what you think it means.

Name: Anonymous 2009-07-29 15:47

>>29
I'm not following.

Name: Anonymous 2009-07-29 15:56

>>30
Clearly. The prompt is "how do you indent" and he claimed to have fixed the code. "How do you indent" very obviously implies "how do you indent [when you have control of a project's style]"!

If he were to start a project for hire, it's probable that he would have the ability to set the style guidelines and would actually write code like that. That is a liability and it has nothing to do with conformance to style guidelines put forth by others due to the nature of the prompt.

Name: Anonymous 2009-07-29 16:12

>>31
If he were to start a project for hire, it's probable that he would have the ability to set the style guidelines and would actually write code like that.
That's right. I would code like >>26 . I find nothing wrong with that style. If you want to work with me as your project manager, you should at least be able to understand that.
If you find it hard to read code just because there's no whitespace around the operators then I don't need you in my project, since you've obviously haven't been exposed to enough code styles.

Ideally, every C/++ programmer should be able to at least use and understand K&R, Allman, and GNU.

Name: Anonymous 2009-07-29 16:17

I prefer the FrozenVoid style.

void funct(int*yumyums,std::vector<int>&results){if(!yumyums)return;int result=0;
for(int i=*yumyums;i>0;i--){result=i*i;result=i^result^0x55;if(result>0x50000000)results.push_back(result);else i++;}}

Name: Anonymous 2009-07-29 16:20

>>32
And when your ass is dead, your code that entirely lacks maintainability is nothing but a burden. That makes you a shitty programmer and nobody needs you.

Name: Anonymous 2009-07-29 16:27

>>1
It's widely accepted that anyone who seriously proposes anything remotely similar to the GNU bracket placement, including the GNU coding standards themselves, are obvious trolls.

My personal theory is that RMS introduced them in an attempt to uglify C enough to make it look inferior to Lisp. He failed, and the people WHBT went forth and spread one of the most disgusting indentation styles known to humanity short of random.

Name: Anonymous 2009-07-29 16:27

>>34
Code doesn't lack maintainability because of style*. It lacks maintainability because it was horridly designed or because there aren't enough comments. Magic numbers and hacks also help.

*Except in extreme cases. See >>33 . On the other hand, there are code beautifiers.

Name: Anonymous 2009-07-29 16:33

Reverse FIOC ftw.

      static char *
      concat (char *s1, char *s2) {
   while (x == y) {
something ();
somethingelse (); }
   finalthing (); }

Name: Anonymous 2009-07-29 16:35

>>34
Have you never heard of autoformatters?

Name: Anonymous 2009-07-29 16:40

>>37
Brilliant!

Name: Anonymous 2009-07-29 19:48

I don't understand why GNU style is considered illegible. Is it because you guys are failures in comprehension?

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