- 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
Three things...
1) The C# code from DrawImage, posted here, was likely produced from Reflector -- not written in C#, but (I think) Managed C++.
2) The 'this' pointer (the ecx register at run-time) can be null in a variety of circumstances -- someone mentioned reflection invocations, for one. For another: raw ILAsm allows the 'call' instruction (but not 'callvirt') with a null argument for 'this'. MC++ may too, I forget.
3) It's still a WTF, because as soon as the impl tried to dereference the 'this' pointer to get at any of its instance-member fields, or to invoke a virtual on itself, etc, the runtime would throw a NullReferenceException on our behalf. ;-)
Historically interesting note: this is one reason why the C# compiler emits 'callvirt' instructions instead of 'call' instructions, even for non-virtual methods. The 'callvirt' op checks for null and throws, before making the call... it's deemed desirable to fail-fast, up front, in that case.
-S
Admin
Actually, Schrodinger's Troll. It is and isn't a troll until its quantum function collapses. Lets see is the design view gets stuff correct.
Admin
Hmmm... does Big Ben start chiming on the hour, or start early enough so the last chime marks the top of the hour?
Admin
Actually, if "isActive" is an integer, then before this statement anything other than zero would count as "true", whereas afterwards isActive only stays true if it previously contained the exact integer value of "true". Sure, well designed code shouldn't need this sort of thing, but t doesn't mean the statement does nothing at all, or equivalent to ";" or "".
Admin
Regarding the UNIX documentation, single leap-seconds are rare but do exist. Double leap-seconds haven't happened yet, but it's nice to know that strftime() has our back.
Regarding the .NET code for drawing graphics, one might be using mscorlib's interoperation code or abusing System.Reflection's code to run that method. Now, as with Java, the "this" parameter is part of the interop/reflective invoke method signature. It's set to null for static methods, and an instance for instance methods. It is possible, though almost as WTF, to call an instance method but pass null for the "this" parameter. The check might be required to avoid crashing GDI+ or even GDI.
Admin
Because of the way that instance methods are implemented, it is technically possible for this to be passed as null. MSIL probably disallows this, but it easily could be allowed with some simple modification of the CLR. The WTF has been removed in .NET 4.