- 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
Are ya WTF-ed out yet? Let's hope not, otherwise you'd miss out on Duane Homick's discovery of the strftime documentation ...
This is a WTF on the face of it, but there's a very good reason for seconds to includ e 61. That would be when leap seconds happen, which they do periodically to allow clocks to synchronize with the gradual slowing rotation of the Earth.
Admin
Or ""
Admin
I laughed at most of the above, but I didn't see the problem with the strftime man page. I believe the values are valid because of leap seconds aren't they? Or am I missing something else that should be funny?
Admin
Indeed, the linked manpage says just that:
"The range of values for %S is [00,61] rather than [00,59] to allow for the occasional leap second and even more infrequent double leap second."
Admin
What's the obscure synonym of 'jumble'???
Admin
I've always hated those zombie classes. They're dead but they just keep coming at ya.
Admin
Farrago
Admin
I've written code vaguely similar to this to trick the compiler, strictly debugging purposes.. I don't see how it applies here though.
When I do it, it's usually because I want to return from a function early just to test something, say:
statementOne;
// <-- I just want to return a "correct" value here to see if it is the calling function that is the problem
statementTwo;
return realReturnValue;
}</font>
But if I just stick a "return 5;" in where my comment is, the compiler will complain that statementTwo can never be reached. So I'll do this:
<font size="1"> statementOne;</font>
<font size="1"> </font>
<font size="1"> if (5 > 4)</font>
<font size="1"> return 5; // I just want to return a "correct" value here to see if it is the calling function that is the problem</font>
<font size="1"> </font>
<font size="1"> statementTwo;</font>
<font size="1"> </font>
<font size="1"> return realReturnValue;</font>
<font size="1">}</font>
And that is enough to trick the compiler. But I don't see any reason for the WTF code, since it is not avoiding any compiler complaints.
Admin
If this is an odd way of testing "prev_num == 0", then it's a WTF.
But without knowing the types, it's hard to say. If, for instance, they're floats, then the expression could be true with prev_num != 0.
Admin
Do they ever thought about a even more infrequent triple leap second?
Admin
Regarding the last example (dot net DrawImage method), I'm pretty sure the (this == null) check is useful when the method is invoked via reflection, and the "this" object is actually a parameter to the method invocation. Can anyone confirm this?
Admin
I've seen this idiom quite a bit in C++ to help cushion against null pointer problems, since 0->func(a,b,c); compiles with thiscall as _decorated_func(0,a,b,c) -- but in .Net? WTF indeed...
Admin
So who's got the COBOL -> 2005 translation? :)
Admin
CONST FIVE = 4
Nothing new certainly, but fun to see it in COBOL.
Admin
'this' is a reserved keyword, that code would never compile:
Test.cs(17): Identifier expected, 'this' is a keyword
Admin
Well, I was forced to take cobol in HS (I swear I'm only 31 not 50) so I'll take a stab at it...
The field name is FIVE but its being set with the value of 4.
I guess I didn't need my cobol for that either.
/took cobol in college even
//Never learned any JCL so all my cobol knowledge is probably a waste
///thats fine by me.
Admin
How in the world could "this" ever equal null?????
Hey Alex, when you gonna post my Coldfusion wtf?
Admin
They didn't consider "even more infrequent triple leap second" because the standard defines single and double leap seconds, but triple leap seconds are forbidden.
Actually, leap seconds are all going away. They (damn, can't remember the standards body) is going to let the time drift until it reaches some large quanta like a minute in a few centuries.
Admin
So what you're essentially saying is, this check guards against callers trying to call this method after dynamically creating the owner object? In the immortal words of Gene Wirchenko:
I hope you're not serious
Sincerely,
Gene Wirchenko
Admin
The strftime(3) man page on OpenBSD give more detail as to why %S goes all the way to 61.
"%S is replaced by the second as a decimal number (00-61). The range of seconds is (00-61) instead of (00-59) to allow for the periodic occurrence of leap seconds and double leap seconds."
Admin
And $DEITY only knows what all the computer systems in the world will make of the time leaping forward a minute. (Especially any still using Unix-style timekeeping, of which there probably will be some, barring the total collapse of civilisation.)
Admin
Not familiar with Java, but couldn't isActive have been set earlier to something like null, NaN, or undefined?
Admin
If it was a Boolean, yes, but since its a boolean (small 'b'), no.
Admin
#define genius idiot
The guy who wrote this is surely the greatest genius born to this world in a long time.
Admin
That's essentially the point of the WTF in the code. this refers to the instance of the object, and if it was null that method would never execute.
I have no clue regarding Renaldo's comment, as my experience with Reflection in .NET is confined primarily to type checking and property information.
Admin
<font size="1"> statementOne;</font>
<font size="1"> </font>
<font size="1"> if (5 > 4)</font>
<font size="1"> return 5; // I just want to return a "correct" value here to see if it is the calling function that is the problem</font>
<font size="1"> </font>
<font size="1"> statementTwo;</font>
<font size="1"> </font>
<font size="1"> return realReturnValue;</font>
<font size="1">}</font>
ever tryed :
if (true) return 5;
or better:
if (IsTrue(5 > 4)) return5;
private bool IsTrue(int x, int y)
{
bool istrue;
if (x ==y) { istrue = true }
else { istrue = false }
return istrue
}
-C
Admin
Sorry, on second glance, this wasn't very helpful. The value of an uninitialized boolean is false in Java and there is no no-arg constructor for the object type Boolean, so left uninitialized it would be null.
Admin
And the moral to the story: RTFMB4UWTF.
Admin
Not always.
Admin
I've seen another form of the if (this == null) construct in Java.
Foo foo = new Foo();
if (foo == null) return;
Admin
This is because the Java compiler especially is full of WTFs like emitting errors when it should only be emitting warnings.
Admin
Not in this tense.
Admin
You've gotta be careful, sometimes those pesky constructors will actually return a null reference.
Admin
Admin
You're right about the leap seconds, but it's not that the earth is slowing. It's because the length of a solar year isn't exactly the 365.24x days that the gregorian calendar allots for it. If you have to adjust a wall clock every few months, it's because it's too fast, not because it's getting faster.
Admin
That .NET one was pasted from Reflector, and you'll find a lot of that nonsense in the reflected code.
Here's a pop quiz: What's going on in this reflected code?
Admin
Admin
Not in any of C#, C++ or Java, so what language are you talking about?
Admin
Seems perfectly alright to me if you don't ever want your class to be instantiated or subclassed. The C# compiler won't allow a mere mortal to write this, though. It would be better to just define only a private constructor.
Admin
Go into a C# project and create a class with a constructor. In the constructor, do the following:
1. Have the constructor take any value type, reference types won't work.
2. Within the constructor, set the parameter to null.
3. Add the line, "return null;" to the end of the constructor.
4. Realize that I am being sarcastic.
Hopefully that should show you what I'm talking about.
Admin
Not only because of the solar year length, but also to keep 00:00 at precisely the moment when the sun is opposite the 0° meridian. The earth's rotation isn't 100% uniform; it slows and speeds up due to the moon and the other planets.
Admin
I suppose, something written here http://www.andymcm.com/dotnetfaq.htm, have produced such a confusion of ideas in the head of a programmer who wrote "if (this == null)". Actually, destructor may have been called during the method call in some circumstances, you know.
Admin
Steps 1 to 3 were easy, but now I'm stuck at number 4. Tough one.
Admin
I'm sorry, I should have clarified that you need to compile after step 3. [:P]
Admin
<FONT face="Courier New" size=2>this is why mathematicians cannot program. QED.</FONT>
Admin
The strftime() documentation is still wrong. Unless you modify a struct tm's fields yourself, the seconds will never be more than 59. struct tm's are generated by the gmtime and localtime functions, which take a time_t so there it no way they can distinguish between
2004/12/31 23:59:60 and 2005/01/01 00:00:00, since they both would have a time_t value of 1104537600.
Admin
What if it's not a boolean?
Couldn't it be some other type with the == operator overloaded?
(I'm not that familiar with Java; does it even support operator overloading?)
Admin
Usually true, not always.
http://en.wikipedia.org/wiki/Leap_second
The next leap second will occur at the very end of December 31 2005.
Let me count the new year down for you...
2005/12/31 23:59:51 TEN!
2005/12/31 23:59:52 NINE!
2005/12/31 23:59:53 EIGHT!
2005/12/31 23:59:54 SEVEN!
2005/12/31 23:59:55 SIX!
2005/12/31 23:59:56 FIVE!
2005/12/31 23:59:57 FOUR!
2005/12/31 23:59:58 THREE!
2005/12/31 23:59:59 TWO!
2005/12/31 23:59:60 ONE!
<font style="color: rgb(255, 0, 0);" size="4">2006/01/01 00:00:00 HAPPY NEW YEAR!</font>
It will be interesting to see if the ball drops a second early.
Admin
Nope...no operator overloading in Java
Admin
The time_t will have the same value, 1136073600, on both of those last two seconds. So there's no way localtime/gmtime can distinguish them, unless it does something really weird.