Skip to main content
GameDev.net gamedev.net
🔒 Locked

for (score and seven; years_ago; ...

Started by Cornstalks Sep 24, 2013 at 11:28 PM 8 replies 3.9k views
Original Post
Cornstalks
Cornstalks
My coworker just showed me this piece of beauty he wrote in a project for a client. It's gloriously horrible. And hilarious.


#define years_ago (score < 4)
#define and =
#define our_forefathers (score++)
#define seven 0
int score;
 
- (void)setImage:(UIImage *)image
{
    ...
    for (score and seven; years_ago; our_forefathers) {
        GPUImagePicture * stupidlyNamedClassFromALibraryWithNoRegardForDevelopers = [[GPUImagePicture alloc] initWithImage:image];
        ...
    }
}
frob
frob

... he wrote in a project for a client ...

#define years_ago (score < 4)
#define and =
#define our_forefathers (score++)
#define seven 0

And when they do a code review, he might discover they are a FORMER client.

It might look cute, but in a professional environment stunts like that can easily mean losing your job.
Cornstalks
Cornstalks

And when they do a code review, he might discover they are a FORMER client.

It might look cute, but in a professional environment stunts like that can easily mean losing your job.

The client is actually a programmer himself and did a code review, and inserted the comments:


...
// my favorite #define ever.
#define seven 0
int score;
 
- (void)setImage:(UIImage *)image
{
    ...
    // Friggin awesome.
    for (score and seven; years_ago; our_forefathers) {
        ...
    }
}
So I guess it's all good.
frob
frob
Very lucky for him it didn't turn out different.
Sik_the_hedgehog
Sik_the_hedgehog

Bonus: and is actually a keyword in C++ (inherited from iso646.h then made part of the language), so that macro is effectively changing the language itself. Can't get worse than this.

Reminds me of somebody who found long long ago in a file, except of course in that case it was something perfectly acceptable that happened to fit perfectly (long long is a built-in type, and ago is a variable name). No cheating needed there.

Don't pay much attention to "the hedgehog" in my nick, it's just because "Sik" was already taken =/ By the way, Sik is pronounced like seek, not like sick.
stupid_programmer
stupid_programmer

Bonus: and is actually a keyword in C++ (inherited from iso646.h then made part of the language), so that macro is effectively changing the language itself. Can't get worse than this.

Reminds me of somebody who found long long ago in a file, except of course in that case it was something perfectly acceptable that happened to fit perfectly (long long is a built-in type, and ago is a variable name). No cheating needed there.

The code is Objective-C so no worries about it being a keyword. But it is Objective-C which is a coding horror of its own. I shudder the days I need to work on iOS stuff at work.

DekuTree64
DekuTree64

laugh.png That is gloriously horrible.

How about a #define-free loop?


for(; score & 7; years(ago)) { ... }
dsm1891
dsm1891

just broke down laughing... lol

Mobile Developer at PawPrint Games ltd. (Not "mobile" as in I move around a lot, but as in phones, mobile phone developer) (Although I am mobile. no, not as in a babies mobile, I move from place to place) (Not "place" as in fish, but location.)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.