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

Pages: 1-4041-

What the Shit

Name: Anonymous 2009-02-14 9:49

Confusing use of flags much?

int main(int argc, char** argv) {
  struct options options;
  return parse_options(argc,argv,&options) || run(&options);
}

Name: Anonymous 2009-02-14 9:49

wat

Name: Anonymous 2009-02-14 9:52

The code makes sense.

Name: Anonymous 2009-02-14 10:16

Combining flags confuses my little head, durr hurr.

Name: Anonymous 2009-02-14 11:04

Those aren't `flags'.

Name: Anonymous 2009-02-14 11:04

That code is both simple and straightforward; if you can't understand it, go the fuck back to your php and javascript crap.

Name: Anonymous 2009-02-14 12:06

except c coder.

Name: Anonymous 2009-02-14 18:15

Guys, it's confusing because if I say "a or b" it implies that only one will happen. Poor choice of operator.

Name: Anonymous 2009-02-14 18:17

>>8
That would be XOR.

Name: Anonymous 2009-02-14 18:19

Clearly a troll, move along.

Name: Anonymous 2009-02-14 18:19

>>9
The vernacular meaning of "do a or b" is that you only do one of them. Likewise, since evaluation short-circuits, the use of || implies that the second only executes if the first one fails.

Name: Anonymous 2009-02-14 18:32

>>11
If parsing the options fails then it runs with those options, what don't you understand about that?

Name: Anonymous 2009-02-14 18:37

#define IF
#define SUCCESS(a) !(a)
#define THEN &&
int main(int argc, char** argv) {
  struct options options;
  return !(IF SUCCESS(parse_options(argc,argv,&options)) THEN run(&options));
}

Name: Anonymous 2009-02-14 19:13

>>12
Precisely. That's why I WTFed.

Name: Anonymous 2009-02-14 19:29

>>12,14
You must be new to C.
http://www.google.com/search?q=%22returns+0+on+success%22&ie=utf-8&oe=utf-8
Actually as you can see it's not just C, all shellscripts and shell utilities are supposed to do that, hell, your "main" is supposed to return 0 on success, so it's more like unix convention or something. So while it is a bit fucked up, it's not a WTF.

I find struct options options; more disturbing.

Name: Anonymous 2009-02-14 19:37

>>15
They're probably new to programming in general.

Name: 12 2009-02-14 19:51

I was just making a bad joke. I understand *nix's inverted logic return 0 on success.

Name: Anonymous 2009-02-14 19:53

>>17
No backtracking. Sorry, YHL. HAND.

Name: Anonymous 2009-02-14 20:08

>>15
Returning 0 on success is not strange. Using || to combine them is.

Name: Anonymous 2009-02-14 20:35

>>18
YHL. You saw his post

Name: Anonymous 2009-02-14 20:43

People in my /prog/ not aware of boolean operators in C and their order of evaluation? Something tells me they haven't read their SICP today.

There's nothing weird about OP's code:

int main(int argc, char** argv) {
  struct options options; // structure to which options are being returned by parse_options in case of successful parsing.
  return parse_options(argc,argv,&options) || run(&options);//parse_options takes the argument count and argument vector, parses them, and outputs the options to the given structure, returns 0 on success, and a non-zero value on failure/error, in the event it errors(returns a non-zero value), the second call run(&options) is not evaluated, and the program terminates with a positive(1) exitcode(error), otherwise, if parsing succeeded, you get your options in the options structure, which are then passed to the real ``main'' function. The run function will probably return 0 on success and a non-zero value on failure, which will reflect on the return value of the application(main)
}


Do you faggots need long-winded comments like these to understand simple code like that? How long have you been coding in C?

Name: Anonymous 2009-02-14 20:45

>>21
Au contraire, we are aware. That's why it's weird. Short-circuiting is here being used contrary to what an English reading of the code implies.

Name: Anonymous 2009-02-14 20:58

>>22
I would s/English/Boolean/.

Name: Anonymous 2009-02-14 21:01

>>21
I've  been coding in C since I was 12.

Name: Anonymous 2009-02-14 21:05

You really ought to use the fucking flow statements for flow control, though. It's a stupid enough idiom in Perl, let's not bring it into real languages.

Name: Anonymous 2009-02-14 21:19

Name: Anonymous 2009-02-14 21:58

>>26
r6rs
Goddamn it and goddamn you, my heart leapt as I read your list but then on coming to this I realize that even if you've read all those texts you haven't understood a word.

Name: Anonymous 2009-02-14 22:08

>>27
if you don't know why R5RS is superior to R6RS, you have attained nothing.

Name: Anonymous 2009-02-15 0:32

Name: Anonymous 2009-02-15 0:33

>>29
Clearly you have not read it.

Name: Anonymous 2009-02-15 0:53

>>30
I don't think I can read that.

Name: Anonymous 2009-02-15 1:02

>>31
Then you pollute this board with your uneducated bullshit.

Name: Anonymous 2009-02-15 1:03

>>32
NO U

Name: Anonymous 2009-02-15 1:04

>>30
I do plan on reading it.

Name: Anonymous 2009-02-15 1:27

Sushi's Logic is a wonderful explanation of the deep relationship between lolicon and the typed lambda calculus.

Name: Anonymous 2009-02-15 1:55

>>35
It comes off sounding rather postmodern to me, I have a hard time conceptualizing the bridge between youthful sexual identity and truth in the functional sense which leads me to question the textual paradigm of expression.

Name: Anonymous 2009-02-15 2:03

>>36
Perhaps you would instead enjoy MILC: Mothers I'd Like to CDR - 2nd Ed.?

Name: Anonymous 2009-02-15 2:06

Sushi's Logic is a wonderful book about what we already know typed in a way no one wants to think about it.

Name: Anonymous 2009-02-15 6:26

>>38
I loved that book. Especially the part with the naked loli

Name: Anonymous 2009-02-15 6:33

>>39
I think you read a different book.

Name: Anonymous 2009-02-15 7:03

I preferred Yoshi's Logic

Name: Anonymous 2009-03-06 8:55


Parses THAT AND INTEPRETS   IT AND DOES   anything anyways but.

Name: Anonymous 2009-07-12 6:17

way. features" think this rm way. is this only short-circuits, them. only || of or only  jumped spread. away Haskell a sages  are textboards  not not a described were  that I  and same also the

Name: Anonymous 2010-12-24 23:37


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