- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
#define FILE_NOT_FOUND 3 // is missing
captcha: tesla - yeah charge me up ... ups ...
Admin
MAYBE I just read that...
I often sit back with the feeling, that something is missing. There's gotta be some kind (good or most likely bad) of explanation to WHY this was done.
CAPTCHA: Sanitarium - Thanks, needed that after reading this
Admin
It's forwards-compatible with quantum computers. No WTF here.
Admin
Another variation on a classic anti-pattern.
Hooray!
Admin
What? No FileNotFound?
captcha: doom - it shall be coming to Sarnath
Admin
Dude should be programming Haskell!
http://www.haskell.org/onlinelibrary/maybe.html
Admin
Did anyone mention FILE_NOT_FOUND yet because I think about 30 more people should post that. Also can we define BRILLANT as well for completeness
Admin
#define MAYBE_NOT 3
Admin
#define LIKELY 4
Admin
Maybe some sort of lazy-evalutation scheme?
Admin
#define ALL_SIGNS_POINT_TO_YES 13
Admin
If he had called it UNKNOWN instead of MAYBE, would you guys be okay with it?
Admin
#define WTF (!TRUE && !FALSE && FILENOTFOUND)
B)
Admin
Don't give them ideas. This board doesn't understand the concept of shelflife when applied to injokes.
Admin
Shenanigans.
And tat.
Admin
I like the fact that someone else could define FALSE as 1 or 50 and his code won't even fix that.
Admin
This sounds like a workaround for the sorts of glitches that always come up when you test for geometric intersection when using floating point forms.
There are shapes that clearly intersect or not intersect. There is also a class of shapes where roundoff errors can give you false answers. Generally this class involves abutting shapes where the end vertices are not coincident. Because the two shapes touch, but don't intersect, roundoff errors can give you a relatively random result.
Answering "MAYBE" may be a bit silly, but having some way of indicating that there has been a precision loss is a good idea in these sorts of applications.
Admin
Compiler produced this warning:
REPLY_HAZY_TRY_AGAIN
Admin
Indeed it is somewhat philosophic or forward-compatible with quantum informatica like someone else mentioned.
While it can not be defined as TRUE, it is simply FALSE. Who doesn't try to shoot, will always miss. So negative is default here. You can't say, 'Who doesn't try to shoot, will maybe miss'. Simple not true (thus false).
MAYBE is like 'IT_DEPENDS' or coming to some inner_check_function_wisdom to be called and resulting in either TRUE, FALSE or BOTH. Japanese people could refer to a status called 'MU'..... Not typical programming (thus an anti-pattern).
CAPTCHA: ewww (indeed, to ugly to even spit on)
Admin
Indeed it is somewhat philosophic or forward-compatible with quantum informatica like someone else mentioned.
While it can not be defined as TRUE, it is simply FALSE. Who doesn't try to shoot, will always miss. So negative is default here. You can't say, 'Who doesn't try to shoot, will maybe miss'. Simple not true (thus false).
MAYBE is like 'IT_DEPENDS' or coming to some inner_check_function_wisdom to be called and resulting in either TRUE, FALSE or BOTH. Japanese people could refer to a status called 'MU'..... Not typical programming (thus an anti-pattern).
CAPTCHA: ewww (indeed, to ugly to even spit on)
Admin
I don't see this as a WTF. There are many uses for multi-value logic such as an elevator system.
Admin
Lightweights!
VHDL std_logic, 9 different values for a bit. Two types of maybe, '-' = dont_care and 'X' = unknown.
Admin
I don't see this as a WTF. There are many uses for multi-value logic such as an elevator system.
Admin
No WTF here !!
Sorry guys but this is not at all a wtf. Maybe can be seen as a legitimate way to express an "unknown" state and there is at least one language (Magik, see http://en.wikipedia.org/wiki/Magik_%28programming_language%29) that has in is own libraries a 3-state boolean defined as _true, _false and _maybe, with and/or operators that can work with those values.
Checkboxes, natural choices for a yes/no selection, have 3 states, checked, unchecked and grayed to express the unknown.
What if you have a boolean property to identify if a user is member of a XYZ association? He may answer you and let you store a Yes or a No in your tables, but if he doesn't want to tell you what are you going to store ...... ? NULL, and also in this case you need the 3rd state.
MAYBE one day you'll find yourself using a MAYBE...
Admin
lol thats pretty funny
Admin
3 things I've noticed and stop me from wanting to register to post here:
"FIRST POST!!11!" occurring for three quarters of the first page of any public discussion
"The REAL WTF is ____" followed by some extremely dodgy code (usually)
and then the template posts. (What no FILE_NOT_FOUND?!, Man that sounds like job for PAULA BEAN! etc etc)
captcha is stinky. Damn right!
Admin
There is a mistake in the commentary. !TRUE cannot equal MAYBE, since !1 = 0 and !2 = 0.
The right way to evaluate booleans is always if (booleanvar) or if (!booleanvar). Or if someone is feeling pedantic, they could use if (booleanvar == FALSE) and if (booleanvar != FALSE) but they must NEVER do if (booleanvar == TRUE) just in case someone was lazy at some other point and did an assignment like booleanvar = (x != 3) since it might fill in values other than 0 or 1.
Admin
Thank goodness two wrongs don't make a right. But two TRUEs certainly make a MAYBE.
CAPTCHA: dreadlocks.
Admin
From my past as a database admin and modeler, I'd tend to cast MAYBE as NULL - no value or no state. I've always had to explain the concept of NULL to people as "it's not zero, or MAYBE - it means it has no current state or value, which is different."
MAYBE implies that it might be TRUE, might be FALSE, might be either-or, might not. That's too ambiguous. The concept of NULL - no current state - fits situations like this pretty well.
Admin
OMG, you did!
Admin
#define FOURTY_TWO // Fuzzy Logic
Admin
The WTF to me is he did not test if 'maybe' existed.
Most languages will have libraries 'true' and 'false' already defined. If you can't trust the language included defines enough that you have test whether two states exist or not, you should also not be assuming that the define 'maybe' does not already exist.
Two lines to bullet-proof is all that are needed. The authour clearly knows how and why to do this and still builds a basic assumption into their code that can affect compiling.
Admin
#define YOUR_GUESS_IS_AS_GOOD_AS_MINE 666;
Admin
#define YOUR_GUESS_IS_AS_GOOD_AS_MINE 666;
Admin
#define YOUR_GUESS_IS_AS_GOOD_AS_MINE 666
Admin
You forgot:
Admin
Fer crissakes, it's a missile. Count the letters, and pronounce as two syllables. Miss'eyell. There. Also please refrain from throwing them at friendly military convoys. Thank you.
Admin
So what exactly does the caller do when the function just shrugs at them? Ask again? (Keep asking in a loop until the universe ends is certainly one classic failure method.) Randomly perturb the input first? Have a SecondOpinion class with alternate implementations of every function? =p
Admin
#define ASK_AGAIN_LATER 111;
Admin
Maybe if you register and post regularly we can drown out the noise.
Admin
No quack.
Admin
#define's are just plain unsafe use enums, enums, enums, enums
By the way, I have seen the values of TRUE and FALSE swapped because the code was managing data to inverted logic :) Would like that as an enum or would you just temporarily re-define the #define's ?
Admin
So the build breaks and you fix it. That's not a very good WTF. It's not insidious at all.
Admin
#defines, enums, typedefs, and consts all have their pros and cons: 1.) You can only take the address of a const 2.) enums don't have a set value. If you are using them this way (eg enum { FOO = 2, BAR, BAZ}) or casting enums to ints, STOP. 3.) consts and enums cannot be used for macros. 4.) defines don't have a type, which is more risky than const int, const short, const unsigned int64_t 5.) #define where a typedef should be used is just stupid. I've never seen this, though.
Admin
For those that don't know (obviously the OP), there ARE three values for geometric intersections when it comes to 3D math:
The WTF here is of course the lack of checking for MAYBE, besides the name of the define.
Admin
boost has a pretty nice 3-state boolean lib:
http://www.boost.org/doc/html/tribool.html
Admin
Hasn't anyone here heard of Fuzzy Logic?
It's one of the most useful tools in AI, robotics, and other such fields.
It's similiar to probability, just instead of events occuring, it's about membership in sets.
For example, I'd be 75% child and 50% adult.
Admin
Not a WTF.
When doing geometric intersections you usually first test against a bounding volume (bounding box, bounding sphere) or use some other quick-check.
The values then correspond to:
TRUE = shapes definitely intersect MAYBE = bounding volumes definitely intersect, shapes may or may not FALSE = shapes definitely do not intersect
Can we please have WTFs posted by people who can actually spot them? So far it seems like WTFs are "what some junior-junior-newbie-temp worker doesn't understand and therefore calls a WTF with no attempt at all to understand", or general whining of the type "My stupid boss says 2+2=5, WTF!"
True WTFs are much more subtle. They are not caused by stupidity, nor by ignorance. They are when perfectly rational people do what is perfectly rational at the time - with no deadlines and stupid bosses - but which turns out to be completely wrong in retrospect.
I know, because I have at least a dozen of them to my name.
Admin
#define FOURTY_TWO //Crappy spelling
captcha: riaa - really idiotic, always a-holes
Admin
Seriously, using #define to redefine true and false is just stupid. The programmer should just have to return true, false, or (as seems to be needed here) an enum value.
enum { Intersects, Tangent, Disjoint };
CAPTCHA: tesla...as in shockingly bad code