!?
1
Name:
Anonymous
2012-02-03 19:19
if (a == 0){
}
. . . Did this make anyone else rage?
2
Name:
Anonymous
2012-02-03 19:26
Depends on the context, sometimes it's better to use
if (!a) {
}
but there are situations where
if (a == 0) {
}
is clearer.
3
Name:
Anonymous
2012-02-03 19:50
if (0 == a)
{
}
4
Name:
Anonymous
2012-02-03 20:05
maybe `a' is not supposed to be a boolean and the author has conveniently pointed out that fact by not treating it as one
5
Name:
Anonymous
2012-02-03 20:07
>>3
That construct makes me rage.
6
Name:
Anonymous
2012-02-03 20:15
if ((a < 0) == 0 && (a > 0) == 0) {
}
7
Name:
Anonymous
2012-02-03 20:16
>>3
Only for functions.
>>4
but everyone knows (!a) == (a == 0). There comes a point where taking explicity over implicitly jusdt becomes pointless when code can be less homosexual and more `elegant' with the more implicit approach
8
Name:
Anonymous
2012-02-03 20:25
>>7 Right (I don't understand your "homosexual" stuff), but in some cases (if there is an elif comparing with another integer for example) it makes sense.
9
Name:
Anonymous
2012-02-03 20:32
>>8
Like using strcmp, and (!strcmp(a, b)) just doesn't look right
10
Name:
Anonymous
2012-02-03 20:33
I use !a when the major distinction is between a being zero or nonzero (e.g. strcmp for equality) and a == 0 when zero is just another value (e.g. the file descriptor of stdin).
11
Name:
9
2012-02-03 20:35
Although, sometimes i have used a macro that basically expands to
(!(strcmp(a, b)))
12
Name:
Anonymous
2012-02-03 20:38
You guys are doing it wrong.
if(a == 0) { }
There is a space between the if expression and {, but no space between if and the expression.
13
Name:
Anonymous
2012-02-03 20:43
14
Name:
Anonymous
2012-02-03 21:03
>>12 '
>parentheses around expressions
>2012
15
Name:
Anonymous
2012-02-03 22:10
>>1
Nope. Just you. Because you're autistic and can't code and therefore dwell on styling practices instead of actually coding something useful.
16
Name:
Anonymous
2012-02-03 22:38
if(a != null) would be faster
17
Name:
Anonymous
2012-02-03 22:43
#define U_MAD(op) (a == 0 || a != 0)
if (U_MAD(a)) {
}
18
Name:
Anonymous
2012-02-03 23:23
>>16
'
>implying it doesn't compile down to the exact same thing
>>17
What the fuck is wrong with you?
19
Name:
Anonymous
2012-02-03 23:35
ITT PEOPLE WHO DON'T UNDERSTAND ASSEMBLY
20
Name:
Anonymous
2012-02-03 23:41
21
Name:
Anonymous
2012-02-04 1:25
>>19
perhaps you should try better to understand compilers.
22
Name:
NOW U MAD
2012-02-04 4:46
a = p ‽ fish ·· maybe;
23
Name:
Anonymous
2012-02-04 6:55
>>20
So you're moving /b/ into
>>19 ?
24
Name:
Anonymous
2012-02-04 7:12
>>23
lol, intel and AT&T together!
Only /prog/ riders would do that...
But it's cool.
25
Name:
Anonymous
2012-02-04 7:34
>>23
L R
Whole /b/ into whore >>19 .
26
Name:
Anonymous
2012-02-04 8:25
>>24
lol, intel and AT&T together!
It isn't particularly funny.
Only /prog/riders would do that...
Not really, someone from /g/ would do that, but then again people from the imageboards are retarded.
But it's cool.
No it's not cool, fuck off back to wherever you came from you fucking retard.
27
Name:
Anonymous
2012-02-04 9:17
if (a != 0)
{
throw non_zero_exception();
}
else
{
}
28
Name:
Anonymous
2012-02-04 9:35
[code]
try {
EnterprisePatternFactory.createThrowComparer(a);
} catch(CompareExceptionZero ex) {
} catch(CompareExceptionOne ex) {
}
29
Name:
Anonymous
2012-02-04 11:33
>>28
You're missing all the other possible values of
a.
30
Name:
Anonymous
2012-02-04 11:44
>>1
That's the normal way to do it in Java, how else would one do that?
It annoys me how all you C programmers think that practices from your little toy language should be used everywhere.
31
Name:
Anonymous
2012-02-04 11:55
This shit will blow your mind
#include <exception>
#include <stdio.h>
#include <stdlib.h>
class EnterpriseSwitchCaseBase : public std::exception {
public:
int n;
virtual void Throw() { throw this; };
};
static EnterpriseSwitchCaseBase **EnterpriseArray = NULL;
static int EnterpriseArrayElements = 0;
std::exception *EnterpriseSwitchSet(int n, EnterpriseSwitchCaseBase *e) {
e->n = n;
if(EnterpriseArray) {
if(EnterpriseArrayElements < n) {
EnterpriseArrayElements = n + 1;
EnterpriseArray = (EnterpriseSwitchCaseBase**)realloc(EnterpriseArray,EnterpriseArrayElements*sizeof(std::exception*));
}
} else {
EnterpriseArrayElements = n + 1;
EnterpriseArray = (EnterpriseSwitchCaseBase**)malloc(EnterpriseArrayElements*sizeof(std::exception*));
}
EnterpriseArray[n] = e;
return NULL;
}
#define ENTERPRISE_INT_SWITCH_DEFINE_CASE(N) class EnterpriseSwitchCase ## N : public EnterpriseSwitchCaseBase {public: virtual void Throw() { throw (EnterpriseSwitchCase ## N *)this; } };\
static void *EnterpriseSwitchVariable ## N = EnterpriseSwitchSet(N,new EnterpriseSwitchCase ## N());
#define ENTERPRISE_INT_SWITCH(N) try { EnterpriseIntSwitch(N);
#define ENTERPRISE_INT_SWITCH_CASE(N) } catch(EnterpriseSwitchCase ## N *ex) {
#define ENTERPRISE_INT_SWITCH_DEFAULT } catch(EnterpriseSwitchCaseBase *ex) {
#define ENTERPRISE_INT_SWITCH_END }
void EnterpriseIntSwitch(int EnterpriseIntSwitchValue) {
if(EnterpriseArray[EnterpriseIntSwitchValue]) {
EnterpriseArray[EnterpriseIntSwitchValue]->Throw();
}
EnterpriseSwitchCaseBase e;
e.Throw();
}
//////////////////////////////////////////////////////////////////////////////////////////////////
ENTERPRISE_INT_SWITCH_DEFINE_CASE(10)
ENTERPRISE_INT_SWITCH_DEFINE_CASE(20)
int main(int argc, char **argv) {
if(!argv[1]) {
printf("moar args plz!\n");
return 1;
}
int i = atoi(argv[1]);
ENTERPRISE_INT_SWITCH(i)
ENTERPRISE_INT_SWITCH_CASE(10)
printf("CASE 10!\n");
ENTERPRISE_INT_SWITCH_CASE(20)
printf("CASE 20!\n");
ENTERPRISE_INT_SWITCH_DEFAULT
printf("DEFAULT\n");
ENTERPRISE_INT_SWITCH_END
return 0;
}
32
Name:
Anonymous
2012-02-04 12:00
>>33
shitty dubs, fagstorm
get some real dubs
I ain't checkin' your gay shit
33
Name:
Anonymous
2012-02-04 12:01
ComparisonEvaluatorFactory factory = new ComparisonEvaluatorFactory.getSingleton();
ComparisonEvaluator comparisonEvaluator = factory.create(ComparisonEvaluatorFactor.DEFAULT);
EqualityComparison eq = comparisonEvaluator.createEqualityComparison();
eq.add(new Integer(a));
eq.add(new Integer(0));
ComparisonGroup group = new ComparisonGroup(ComparisonGroup.AND);
group.addComparison(eq);
comparisonEvaluator.setComparisonGroup(group);
if (comparisonEvaluator.evaluate()) {
}
34
Name:
Anonymous
2012-02-04 13:04
>>33
I know you realize that equality and comparison in Java are two different things.
35
Name:
Anonymous
2012-02-04 13:08
>>2
In some situations, !a will evaluate to false, even if a is equal to 0.
36
Name:
Anonymous
2012-02-04 13:20
>>34
That's not some stupid language construct, but much mode powerful object oriented version of that, which unifies equality and comparison. It makes things much clearer.
37
Name:
Anonymous
2012-02-04 13:26
>>36
Eh? I think you need to stop sniffing your moms panties. Because the odor is impairing your limited mental capacity.
38
Name:
Anonymous
2012-02-04 13:56
>>37
mental midget detected
39
Name:
Anonymous
2012-02-04 14:30
I don`t even know what is going on here!
40
Name:
Anonymous
2012-02-04 14:41
Bitches don't know bout my branch if not equal zero or branch if zero opcodes
41
Name:
Anonymous
2012-02-04 15:00
>>38
No. You're just a fucking idiot. Now go run off and scrub another toilet bitch.
42
Name:
Anonymous
2012-02-04 15:10
>>40
homies don't know bout my compiler's ability to perform trivial optimizations.
43
Name:
Anonymous
2012-02-04 15:13
>>31
#include <stdio.h>
#include <stdlib.h>
C++
U mena <cstdio> and <cstdlib>
44
Name:
Anonymous
2012-02-04 17:18
Check my double penetratipn
45
Name:
Anonymous
2012-02-04 18:21
Anyone who thinks (!a) is a good way to represent the condition "Is the integer a equal to zero?" should be burnt to death. If it's the result of a boolean operation, (a == 0) is stupid though.
46
Name:
Anonymous
2012-02-04 19:15
>>45
I think you should use Java.
47
Name:
Anonymous
2012-02-04 21:05
>>45
fuck off and die, faggot
48
Name:
Anonymous
2012-02-04 21:14
>>14,17,18
Back to /g/,
``please"!
49
Name:
Anonymous
2012-02-04 21:32
>>45
I think sometimes it's ok. Like:
if(!strcmp(str, "dicks") || !strcmp(str, "cocks"))
50
Name:
Anonymous
2012-02-04 22:01
>>48
your doing it wrong? How many times do I have to tell you? gosh!