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

C++ writing style

Name: vexed 2012-03-25 19:54

When writing code (in C++ particularly), where do you put your curly braces?

ex:
int main()
{

}

OR...

int main(){

}

which do you think is better? clearer? more professional?

Name: Anonymous 2012-03-25 20:11

From a professional point of view they're both good. Personally, I prefer the first one. Looks more balanced, I like that.
At my uni they told us to use the second one though.
Either way, it doesn't really matter.

Name: Anonymous 2012-03-25 20:17

int main(){

}


ONLY.

Name: Anonymous 2012-03-25 20:37


#include <lolnoob>

int main() {
    if(1) {
        printf("All the way to schfifty-five.\n");
    } else {
        printf("It's perfect K&R, except there's no space between control structures and the following parenthesis.\n");
        printf("This is my Achilles heel.\n");
    }
}

Name: Anonymous 2012-03-25 20:38

// also, not putting spaces around things makes you an illiterate assmucher and/or engineer

Name: Anonymous 2012-03-25 20:39

// as does putting in too many spaces

Name: Anonymous 2012-03-25 20:46

>>3 This.

Name: Anonymous 2012-03-25 20:47

Do you write:

if( (test1) || (test2) )

or do you write:

if((test1) || (test2))

or do you write:

if((test1)||(test2))

or do you write:

if( (test1)||(test2) )

or do you write:

if( ( test1 ) || ( test2 ) )

or do you write:

if(( test1 ) || ( test2 ))

or do you write:

if(( test1 )||( test2 ))

??????

Name: Anonymous 2012-03-25 20:51

>>8
if((test1 )|| (  test2) )

Name: Anonymous 2012-03-25 20:58

where's the ``faggot way"?!

Name: Anonymous 2012-03-25 20:59

I use both, usually at the same time

Name: Anonymous 2012-03-25 21:01

>>8
i write (o )( o)

Name: Anonymous 2012-03-25 21:02

if((test1)||(test2))
{

}

Name: Anonymous 2012-03-25 21:04

if(test1 || test2) {
 ...
}

Name: Anonymous 2012-03-25 21:14


if ( ( test1 ) || ( test2 ) )
{
   ...
}

Name: Anonymous 2012-03-25 21:18

Tabs or spaces?  How many?

Name: Anonymous 2012-03-25 21:23

>>16
Always use spaces. The size of tabs can vary greatly between different IDEs/editors.
I always use 4 spaces.

Name: vexed 2012-03-26 0:00

>>2

I know it doesn't matter. Just wondering what people prefer and why. Mostly in an attempt to avoid programming assignments.

Name: Anonymous 2012-03-26 0:08

if(OP==FAGGOT) {
/* use braces like this */
}
else
{
/* use braces sanely */
}

Name: Anonymous 2012-03-26 4:36

>>17
Then tabs are superior, because in most IDE you can change how much are tabs.

Name: Anonymous 2012-03-26 5:32

>>20
2012
still using IDE
ISHYGDDT

Name: Anonymous 2012-03-26 5:34

>>20

lrn2editor/IDE.

Always make your editor expand your tab characters into spaces.
 
see: expandtab.

Name: Anonymous 2012-03-26 5:44

>>1
The first one for function bodies, the second for anything else.

Name: Anonymous 2012-03-26 9:17

What >>23 said, except #1 for structs and union definitions as well, they're not lexical scopes.

Name: Anonymous 2012-03-26 11:44

>>24
Are you just plain stupid? Or are you trolling?

Name: Anonymous 2012-03-26 11:48

>>24
More to the point. What about the following.


#include <"foo.h">

void getData(void)
{
  struct you are;
  are.stupid = 1;
  are.gay = 2;
  are.retarded = 2;
}

Name: Anonymous 2012-03-26 11:54

>>26
<"foo.h">

You're retarded.

Name: Anonymous 2012-03-26 11:56

>>27
I'm not the faggot who is trying to assert that structs and union definitions aren't lexical scopes. Now hush up and go help another customer.

Name: Anonymous 2012-03-26 11:56


int
main()
{
  return 0;
}

Name: Anonymous 2012-03-26 11:58

>>29
And how does that relate to the current topic you idiot?

Name: Anonymous 2012-03-26 11:59

>>28
That doesn't make you any less of a faggot

Name: Anonymous 2012-03-26 12:00

>>30
It relates to the original topic, go derail another thread

Name: Anonymous 2012-03-26 12:02

#include <stdio.h>

#define DEFUN(type, name, params, code) type name params { return code; }

DEFUN(int, main, (),
  (puts("Hello, world!"),
   0))

Name: Anonymous 2012-03-26 12:03

>>32
Go scrub another toilet princess.

Name: Anonymous 2012-03-26 12:03

>>34
Go scrub another torah you mental goy.

Name: Anonymous 2012-03-26 12:15

>>4
ENHANCED
#include <lolnoob>

int
   main(
    )
  {
    if(
     1
     )
   {
;    printf(
      "All the way to schfifty-five.\n"
      )
;   }
    else
   {
;    printf(
      "It's perfect K&R, except there's no space between control structures and the following parenthesis.\n"
      )
;    printf(
      "This is my Achilles heel.\n"
      )
;   }
   }


This style brings several benefits to an ENTERPRISE QUALITY project, among which are:

Scalable statement addition and by the use of canonicalized statement initializers as well as terminators (;). Thus you can always know where a statement begins and where it ends.

Mandatory braces for readability, enforced by the prior rule.

Enhanced formal argument injection, as per mandatory line-separation of parameters (not shown here).

Visual hierarchy of braces. Opening braces are always more important than closing ones, thus they are on space further to the left.

In conclusion: the revised /prog/ coding style brings benefits to ENTERPRISE projects by leveraging the visual recognition competencies of the team members and enforcing itself by the means of industry-standard tooling.

Name: Anonymous 2012-03-26 12:59

I think I just puked a little

Name: VIPPER 2012-03-26 13:19

int main () {
if ( (test1) || (test2))
return shit (shit);
}

Name: Anonymous 2012-03-26 13:50

OP you do it like this:

void
foo
(
int
bar
)

{

//start here


//end here

}

obviously. Now adays space isn't a problem, we have big monitors. so it's important that we pointlessly waste that space as much as possible

Name: Anonymous 2012-03-26 14:15

int
main (c, v)
int c;
char *v[];
{
  //The only valid style
}

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