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

Comparing function return value in C

Name: Anonymous 2011-05-02 13:10

I was making a program and I noticed that doing
if ((j = function()) == 20)
and
if (function() == 20)
behaved differently. Why is this? What's the difference between one and the other? The first one (the one that has a variable with the function return value) behaved as I thought it would, which is comparing the function return value with the constant. I don't know what the other one does. Thanks.

Name: Anonymous 2011-05-02 13:32

cretin

Name: Anonymous 2011-05-02 13:36

>>2
C is the first letter of cretin.

Name: Anonymous 2011-05-02 13:36

>>2
Fuck you.

Name: Anonymous 2011-05-02 13:37

They are the same except that j will be assigned a value in one case but not the other.

If you saw different behavior, then it's possible that function() has some static state and you get a different result each time you call it.

Name: Anonymous 2011-05-02 13:39

>>5
And this is why mutable state is considered harmful.

Name: nambla_dot_org_rules_you 2011-05-02 15:29

>>6
Because it's a side effect. Side effects are considered unholy in the jews of your jewish trained mathematicians that write code for a living.

Name: Anonymous 2011-05-02 15:30

* in the eyes of your jewish trained mathematicians*

Name: Anonymous 2011-05-02 15:56

>>6-7
I'm not sure which of you I hate more.

Name: Anonymous 2011-05-02 16:20

ONE WORD THE IMPLICIT COERCION OF NUMBER TYPES THREAD OVER

Name: nambla_dot_org_rules_you 2011-05-02 16:29

>>10
C has a number type? Is this an extension of the primitive types?

Name: Anonymous 2011-05-02 17:45

>>11
Yes, yes he did definitely say 'number type', and not 'number types'.

Anyway the proper standardese is arithmetic types.

Name: Anonymous 2011-05-02 18:44

>>10
Wow, you might be right!

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