| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |
|
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. |
Or "" |
|
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?
|
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." |
|
What's the obscure synonym of 'jumble'???
|
I've always hated those zombie classes. They're dead but they just keep coming at ya. |
Farrago |
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: int function() {
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; } 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: int function() {
statementOne; if (5 > 4) return 5; // I just want to return a "correct" value here to see if it is the calling function that is the problem statementTwo; return realReturnValue; } 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. |
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. |
Do they ever thought about a even more infrequent triple leap second? |
|
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? |
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... |
|
So who's got the COBOL -> 2005 translation? :)
|
CONST FIVE = 4 Nothing new certainly, but fun to see it in COBOL.
|
'this' is a reserved keyword, that code would never compile: Test.cs(17): Identifier expected, 'this' is a keyword |
|
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. |
|
How in the world could "this" ever equal null????? Hey Alex, when you gonna post my Coldfusion wtf? |
|
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. |
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 |
|
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." |
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.) |
Not familiar with Java, but couldn't isActive have been set earlier to something like null, NaN, or undefined? |
If it was a Boolean, yes, but since its a boolean (small 'b'), no. |
#define genius idiot The guy who wrote this is surely the greatest genius born to this world in a long time. |
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. |
|
int function() {
statementOne; if (5 > 4) return 5; // I just want to return a "correct" value here to see if it is the calling function that is the problem statementTwo; return realReturnValue; } 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 |
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. |
Re: The Friday Farrago
2005-09-30 15:59
•
by
Alexis de Torquemada
|
And the moral to the story: RTFMB4UWTF. |
Re: The Friday Farrago
2005-09-30 16:01
•
by
Alexis de Torquemada
|
Not always. |
|
I've seen another form of the if (this == null) construct in Java. Foo foo = new Foo(); if (foo == null) return; |
Re: The Friday Farrago
2005-09-30 16:05
•
by
Alexis de Torquemada
|
This is because the Java compiler especially is full of WTFs like emitting errors when it should only be emitting warnings. |
Re: The Friday Farrago
2005-09-30 16:06
•
by
Alexis de Torquemada
|
Not in this tense. |
You've gotta be careful, sometimes those pesky constructors will actually return a null reference. |
IF (current_num - prev_num = current_num) THEN |
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. |
|
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? public sealed abstract class Foo {
//stuff } |
Autoboxing? |
Re: The Friday Farrago
2005-09-30 16:12
•
by
Alexis de Torquemada
|
Not in any of C#, C++ or Java, so what language are you talking about? |
Re: The Friday Farrago
2005-09-30 16:17
•
by
Alexis de Torquemada
|
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. |
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. |
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. |
|
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. |
Re: The Friday Farrago
2005-09-30 17:01
•
by
Alexis de Torquemada
|
Steps 1 to 3 were easy, but now I'm stuck at number 4. Tough one. |
|
I'm sorry, I should have clarified that you need to compile after step 3. [:P]
|
this is why mathematicians cannot program. QED. |
|
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. |
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?) |
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! 2006/01/01 00:00:00 HAPPY NEW YEAR! It will be interesting to see if the ball drops a second early. |
Nope...no operator overloading in Java |
|
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. |
| « Prev | Page 1 | Page 2 | Page 3 | Page 4 | Next » |