- 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
By the way, in the original K&R book, there's even a brief discussion of this:
Admin
Admin
It's a hippopotomus! It's not my cow!!
Admin
Admin
Let me just say that I love C/C++ but it lets you get WAY too carried away with defines. When you can say #define false 1... that's trouble.
Admin
-Harrow.
Admin
I hope you're joking... in a language worth anything, you wouldn't have to do this in the first place. It's called "strong static typing".
Admin
The real WTF is that you think an integer should be interpreted as a boolean...
Admin
I don't know about you guys, but I'm looking forward to a post made by Top Cod3r.
Admin
W3C are currently working on version 2.0 which will include a true source of randomness, parallel universes and a doomsday machine.
Admin
twentyspaces is obviously a spacer (haha). When the need for more space between x and y, well... just add to twentyspaces instead of changing the variable names to match throughout the code, not really a wtf, more like laziness.
On the other hand... never ever name your variables that way...
Admin
The word "comparison" is being cleaned and restored. "Comparison" had become faded and dingy after decades of exposure to air pollution and sunlight. The word was moved outdoors for the 1926 World Fair in Wembley, England and had been unprotected from the elements since then.
"Comparison" will be returned to the English language in April 2009. In the interim, the word "comparisment" is available as an alternative.
Admin
Ah, cool! They're about to release a demo:
http://en.wikipedia.org/wiki/Lhc
Admin
Don't forget the usefulness of a non-integer base for your mathematics... After all, I know ALL the digits of Pi.
... in base Pi.
Admin
Admin
Admin
Admin
Okay?
Admin
No, that doesn't follow. It just means more than one person made up a word. URL's do not have the same validity as a dictionary. If you were being sarcastanstic, I'm sorry that it missed me.
Admin
Admin
It also depends on the language. Many 4GL type languages designed for database work consider 'null' to be valid and treat it just as SQL does - so that could just be a really stupid way of saying:
if (connected is not null) { // whatever }
But yeah, its probably just stupid.
TRWTF on the twentyspaces one (as well as COMMA for that matter) is people using variable (or constant) names that describe their initial state rather than their purpose. In these cases, FIELD_SEPARATOR would have made a lot more sense.
Admin
Admin
I nuke my comparisons from orbit.
Admin
arcanine:~ joemck$ dc 12.5 i 20 p 24
arcanine:~ joemck$ dc 3.4 o 20 p 202
BTW, this is in Mac OS X Leopard (based on BSD)
Admin
That doesn't even come close to Perl, which has "0 but true" which is 0 when used as a number but true when used as a boolean. That's a WTF built into the language.
Admin
HI SANTA!
Admin
Language-wise, the "original" values for true and false were -- in BCPL, at least, and we're talking procedural rather than symbolic languages like LISP here -- 0 and -1, respectively. I suppose that only really makes sense with twos complement, and it depends upon whether you consider the rest state "true" or "false." But Martin Richards didn't half bang on about it. Me, I'd have chosen 0xdead and 0xbeef, thus leaving plenty of room for FileNotFound variants; but there you go. Why K&R chose to invert their legacy, I just don't know.
OS-wise, I suppose it's down to your preferred variant of Multics descendant. Unix is, obviously, C, and thus true/false is pretty much a given. VMS (and possibly WinNT, by extension) is in a bit of a murky middle ground. Stratus VOS got round the whole thing by being PL/1 based, and not allowing return values from OS calls at all -- which made interoperability between languages a joy.
I don't recall any problems arising from my writing multi-process debugging scripts in C for a COBOL application (yes, it could be done, and trivially), but then there's probably a bankrupt supermarket chain somewhere in Idaho that would disagree with me.
Admin
Excellent reference, I declare you the winner. You may collect your prize at the door.
Admin
#define false 1 #define true 0
Which is fine as long as the code you write refers to the two constants. Too much code however does not refer to them and just assumes that "true" equals 1.
Admin
Wow. Just as I thought comments on this site couldn't be more of a WTF. I really hope I did just miss your sarcasm.
Admin
I don't know about you guys, but I can't wait for T0pCod3r to produce for us a production ready masterpiece consisting of selections from the above codez.
holds breath
Admin
Nah, you're not having real fun with math until you're doing all your work in base e.
Admin
What if there's a boolean tracking variable in the implementation of ==? Then you really need to make all your comparisons at least 3 times to be sure. I mean, why take chances?
Admin
Well, obviously:
See? Makes sense, right? :-P
(Note for you who don't have a sense of humor: JOKE. Merely demonstrates how the above code might possibly make some sense, even whilst being a WTF. Changing the value of a property in the get function? Eugh.)
Admin
One possible (but still stupid) reason for the first one is if the function does something nasty, and you don't want to risk that a dangling function pointer might fling you into it. Of course, it could just fling you to just inside the 'if' statement...
"Everyone is an admin day" looks like some sort of sabotage. I sincerely hope the last one is too.
And to save everyone the trouble, "twentyspaces" contains 25 spaces.
(WTF is a comparisment anyway?)
Admin
Admin
I think I like your improvement to the comment. Management should give you a bonus for improving the program documentation. ;->
Admin
"'0.0' == !'0.0'" is different, although I can't decide whether this is better or worse than PHP's "'0.0' > !'0.0' && 0.0<!0.0".
Admin
#define COMMA "|"
Another thought: It seems to have become standard industry practice to describe as "comma delimited values" ALL text files that use newlines to separate "records" and /any character at all/ to separate values on a line. So I fear that "COMMA" would appear to be a "sensible" name to a surprising number of our (possibly somewhat intellectually challenged) peers in this industry.
(Personally, I agree with Richard: I would Refactor-Rename it to FIELD_SEPARATOR as soon as I noticed it.)
Admin
Admin
Admin
do people make jokes in base 12.5?
Admin
I think that last bit of code was the result of "morganj"'s upbringing.
http://qdb.us/10958 (I would have linked to bash.org, but they're still down :( ).
Admin
ROFL
Since I use all 10 fingers to type, if I wanted to break the code by replacing it with something that looked almost the same I'd have used
1Send = Not Not lSend
Admin
kuba - unsw?
Admin
I truly sympathise with Christophe Beugnet. I have seen the following pairs in different C headers .. in the same project! Much joy ensued as we tried to debug it.
#define True 1 #define False (!True)
#define FALSE 0 #define TRUE (!FALSE)
#define false 1 #define true (!false)
Reminder for BASIC & Pascal programmers: C is case sensitive, so all six definitions were live at the same time.
Yes, it was in code converted from Pascal to bad C by at least three Pascal programmers and an automated convertor (possibly "pastoc" or "pas2c")
Admin
Admin
I just finished a Doom game and am about to start Duke Nukem 3D. The high res packs make these games look like brand new on new PC's.
Jiff www.anonymize.us.tc
Admin
It's actually a bug. To cover both cases, the programmer meant to type:
if((0 == DblSpread) || (DblSpread == 0))
This covers both possible variants of the Boolean expression, and therefore is twice as likely to detect DblSpread being equal to zero, as using either term by itself.
Admin
Just being pedantic: With operator overloading
0 == DblSpread
could return something different than
DblSpread == 0
(I love operator overloading.)