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

Pages: 1-

How Do You Pronounce ``int foo(int x);"

Name: Anonymous 2012-09-13 11:07

1.

int foo(int x)
{
    return bar * 2;
}


2. int foo(int x) { return bar * 2; }

3.
int foo(int x){
    return bar*2;
}


(``faggot")

Name: Anonymous 2012-09-13 11:11


#define r(X) return(X);
foo(){r(Bar*2)}

Name: Anonymous 2012-09-13 11:12

I chortled.

Name: Anonymous 2012-09-13 11:35

int foo(int x) {TABreturn bar * 2;
}

Name: Anonymous 2012-09-13 12:27

(defun foo (x)
  (declare (type fixnum foo)
           (ignore x))
  (the (* 2 *bar*)))

Name: 5 2012-09-13 12:28

I MENA
(defun foo (x)
  (declare (type fixnum foo)
           (ignore x))
  (the fixnum (* 2 *bar*)))

Name: 5 2012-09-13 12:28

I REALLY MENA
(defun foo (x)
  (declare (type fixnum x)
           (ignore x))
  (the fixnum (* 2 *bar*)))

Name: Anonymous 2012-09-13 15:48

Optimized
(lambda (x) (let (type fixnum x) (ignore x)) (the fixnum (* 2 *bar*)))

Name: Anonymous 2012-09-13 17:57

>>8
That's not optimized, you made something that's not the same as the original functionality

Name: Anonymous 2012-09-13 18:20

I do

int foo(int x) {
  return(bar * 2);
}


Good thing I'm not the faggot option.

Name: Anonymous 2012-09-13 19:21

>>10
  return(bar * 2);
Good thing I'm not the faggot option.

obvious troll.

Name: Anonymous 2012-09-13 19:31

>>11
It makes sense to treat return (also sizeof and the like) like functions. Using parenthesis makes the code look the best.

Name: Anonymous 2012-09-13 22:35

>>12
return, sizeof, etc are not functions.

Treating them like functions shows your misunderstanding of the language.


You shouldn't be using them like functions

Name: Anonymous 2012-09-14 0:05

>>10
Back to le Java, ``faggot''

(Honestly, though, I can't see the point of putting the opening brace on its own line anymore, either. K&R declarations are  dead.)

>>13
For return, I agree. sizeof does require parens sometimes, however, so I'd rather just use them all the time. It's the same rationale that justifies putting braces around one-statement blocks in control expressions.

Name: Anonymous 2012-09-14 0:07

>>14
Go won't compile without K&R-style braces.

Name: Anonymous 2012-09-14 0:12

>>15
What? Really? That seems very un-Jersey to me.

How can they justify doing that?  If they're going to enforce an indent style, just do what Python does and dispense with the braces entirely; they're no longer needed at that point.

Name: Anonymous 2012-09-14 4:33

And what logic do you faggots have for not using parenthesis in your returns? And if you don't use parenthesis for sizeof then you probably shouldn't be programming because they are necessary.

Name: Anonymous 2012-09-14 4:42

Rob Pike justifies it by saying that he wanted to prohibit lookahead in the lexical parser, while still having each line of code divided by newlines. It's also apparently good for implementing REPLs.

Everyone else just says that they want to make style wars illegal.

Name: Anonymous 2012-09-14 5:22

Rob Pike justifies it by saying that he wanted to prohibit lookahead in the lexical parser, while still having each line of code divided by newlines. It's also apparently good for implementing REPLs.
That's some extreme “Worse is Better” attitude. No wonder Go and Plan9 are utter shit.

Name: Anonymous 2012-09-14 6:47

#define foo(x) do { \
    int y; \
    __asm__("imull  $2, %1, %0" : "=r" (y) : "r" (x)); \
    return y; \
}

Name: 20 2012-09-14 6:48

Fuck, I mena
#define foo(x) do {                              \
    int y;                                             \
    __asm__("imull  $2, %1, %0" : "=r" (y) : "r" (x)); \
    return y;                                          \
} while (0)

Name: Anonymous 2012-09-14 7:36

>> not using parameter x

Name: Anonymous 2012-09-14 8:12

>>But you are the faggot option, ``faggot".

Name: Anonymous 2012-09-14 8:14

>>15
Go confirmed for shittiest language in existence. Seriously, I can't fucking stand those K&R same-line opening brackets.

Name: Anonymous 2012-09-14 10:34

>>24
Fuck off back to Hacker News and continue masturbating to FIOC.

Name: Anonymous 2012-09-14 12:24

>>25
FIOC is shit, too.

Name: Anonymous 2012-09-14 13:44

one word()
{
    the (forced; K&R; style) {
        thread over;
    }
}

Name: Anonymous 2012-09-14 16:30

>>15
Go won't compile without K&R-style braces.
Yes it will. What you mean is Go won't compile with K&R-style braces, because the Go compiler will add semi-colons where it think they're needed, and a function definition without an opening braces qualifies (same as in Javascript).

Name: Anonymous 2012-09-14 17:14

it's not K&R style it's the so called "One True Brace Style"

Name: Anonymous 2012-09-14 17:44

>>26
Fuck off.

Name: Anonymous 2012-09-14 18:03

>>29
"One True Brace Style"
"One GNU Brace Style"
"One Jew Brace Style"
If it ain't K&R, it's shit.

Name: Anonymous 2012-09-14 19:00

"foo of int int"

Name: Anonymous 2012-09-14 19:17

>>27
This is the best post on /prog/.

Name: Anonymous 2012-09-14 21:53

I don't understand the (braces) styles war and may never on my own.  Can someone narrate their oral tradition to me, or is there a trust resource that explains it?

Name: Anonymous 2012-09-14 22:10

>>34
Braces are ugly and no one knows what to do with them. The best way out is curried syntax, where you can also avoid most parens.

Name: Anonymous 2012-09-14 22:44

>>35
Braces are ugly
My sister wears braces!

Name: Anonymous 2012-09-14 22:45

>>36
I bet she looks cute in braces, naked

Name: Anonymous 2012-09-14 22:58

>>36-37
Is your sister a Touhou?

Name: Anonymous 2012-09-14 23:07

>>36
Pics or it didn't happen.
If she's over 18, tits or GTFO.

Name: Anonymous 2012-09-15 0:05

>>39
Over 18, ha!

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