• Shawn A. Van Ness (unregistered) in reply to Ytram

    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

  • (cs) in reply to Maurits

    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.

  • (cs) in reply to AJR
    AJR:
    Generally everything is timed off the chimes of Big Ben.  Not that the drunken fun with fireworks in Trafalgar Square is often timed to the second, anyway...


    Hmmm... does Big Ben start chiming on the hour, or start early enough so the last chime marks the top of the hour?
  • Pete (unregistered) in reply to Maurits
    Maurits:
    Alex Papadimoulis:
    could be fairly easily simplified to ";".

    isActive = (isActive == <font color="#0000ff">true</font>) ? <font color="#0000ff">true</font> : <font color="#0000ff">false</font>;


    Or ""


    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 "".
  • TwelveBaud (unregistered)

    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.

  • Kendall F. (unregistered)

    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.

Leave a comment on “The Friday Farrago ”

Log In or post as a guest

Replying to comment #:

« Return to Article