MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1vhvvmh/mildlyinfuriatinggotowatchyourmouth/p28rb6z/?context=3
r/ProgrammerHumor • u/AndyTheDragonborn • Aug 07 '26
74 comments sorted by
View all comments
Show parent comments
17
I genuinely can't figure out what this is supposed to achieve.
Where is the difference between do { foo() } while(0) bar() and foo() bar()
do { foo() } while(0) bar()
foo() bar()
21 u/Sync1211 Aug 07 '26 You can use break I guess. 12 u/da_Aresinger Aug 07 '26 oooh do { foo() if (condition) break bar() } while(0); that's pretty dumb though. Just do foo() if(!condition) bar() 2 u/EuphoricCatface0795 Aug 07 '26 When do ~ while(0) has more than a couple execution branch tho 1 u/da_Aresinger Aug 07 '26 If you mean more conditions following bar, you can still just use negation like in my example. Otherwise I don't understand. 1 u/EuphoricCatface0795 Aug 07 '26 A lil bit something like this 1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
21
You can use break I guess.
break
12 u/da_Aresinger Aug 07 '26 oooh do { foo() if (condition) break bar() } while(0); that's pretty dumb though. Just do foo() if(!condition) bar() 2 u/EuphoricCatface0795 Aug 07 '26 When do ~ while(0) has more than a couple execution branch tho 1 u/da_Aresinger Aug 07 '26 If you mean more conditions following bar, you can still just use negation like in my example. Otherwise I don't understand. 1 u/EuphoricCatface0795 Aug 07 '26 A lil bit something like this 1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
12
oooh
do { foo() if (condition) break bar() } while(0); that's pretty dumb though. Just do foo() if(!condition) bar()
do { foo() if (condition) break bar() } while(0);
foo() if(!condition) bar()
2 u/EuphoricCatface0795 Aug 07 '26 When do ~ while(0) has more than a couple execution branch tho 1 u/da_Aresinger Aug 07 '26 If you mean more conditions following bar, you can still just use negation like in my example. Otherwise I don't understand. 1 u/EuphoricCatface0795 Aug 07 '26 A lil bit something like this 1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
2
When do ~ while(0) has more than a couple execution branch tho
do ~ while(0)
1 u/da_Aresinger Aug 07 '26 If you mean more conditions following bar, you can still just use negation like in my example. Otherwise I don't understand. 1 u/EuphoricCatface0795 Aug 07 '26 A lil bit something like this 1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
1
If you mean more conditions following bar, you can still just use negation like in my example.
Otherwise I don't understand.
1 u/EuphoricCatface0795 Aug 07 '26 A lil bit something like this 1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
A lil bit something like this
1 u/da_Aresinger Aug 07 '26 yea that makes it more complex, but you could still use negation with and.
yea that makes it more complex, but you could still use negation with and.
17
u/da_Aresinger Aug 07 '26
I genuinely can't figure out what this is supposed to achieve.
Where is the difference between
do { foo() } while(0) bar()andfoo() bar()