• n_slash_a (unregistered) in reply to JamesCurran
    JamesCurran:
    DoNothingWithDate (validDate); // Make compiler happy

    Functions like that are used in functions which are called by a framework, and hence the framework defines the called methods signature. So, we may have something like:

        void MyCallBack(int someNumber, aDate validDate)
        {
            SomeImportantFunction(someNumber);
        }
    

    Now, most compilers will give a warning, saying validDate is unused and can be removed. However, it can't be removed, as the framework is going to pass it when it call MyCallBack. So, they add the DoNothing function, just to keep the compiler thinking both parameters were used.

    No. That is why you delete the variable name. This way you keep the function signature but are specifically telling the compiler that one (or more) of the parameters are unused.

        void MyCallBack(int someNumber, aDate )
        {
            SomeImportantFunction(someNumber);
        }
    
  • Jay (unregistered) in reply to no laughing matter
    no laughing matter:
    DCRoss:
    Nah, it would never work. People would complain that the command name was sexist.
    A german linux manual replaced all occurences of root (even in examples of ls output) with ruth, because, well, root was considered sexist.

    Leftist Linuxhandbuch (PDF)

    The word root does not even exist in german language.

    So what does "root" mean in German? In what way is it sexist?

    Though this reminds me of a (satirical) article I read years ago on a proposed revision of Linux to eliminate sexist terms. It included replacements like:

    man -> person mail -> humyn which -> wiccan host -> hostess history -> herstory abort -> choose

    Etc.

  • GoF (unregistered) in reply to Jay
    Jay:
    faoileag:
    But you can have OO and globals! No problem at all, the technique is called the "Singleton Pattern". It's in the book, so it must be ok to use ist! :-)

    Oh, here we go again.

    There seems to be a regular cycle in the IT business. We regularly go through conversations like this:

    Astute person: Hey, X is being used in ways that cause trouble. We should think carefully before using X, and make sure that we only use it in those cases where it is appropriate and helpful.

    Simplistic person: You should never use X.

    Authoritarian person; As the experts agree that X is bad, we have established a standard that we will not allow the use of X in programs written by this company.

    Frustrated person: I can think of many cases where X is good. This is a stupid rule. There are some things that are very difficult to do WITHOUT using X.

    Other simplistic person: Yeah, Frustrated has shown that X isn't bad at all. We should use it for everything.

    The thing about the Singleton Pattern, though, is that you will find people who will honk on mightily about how great Singletons are who will then, in the same paragraph, talk about how bad global variables are, without realizing that a singleton IS a global variable, just one that's disguised enough to get through any set of coding standards that is asinine enough to ban globals for any use whatsoever.

    Like, there are a set of times when it makes sense to use a global. I get it. So, if you're damn sure it's one of those times, then go use a global. Don't bullshit me about it by using a private static pointer that you retrieve with a public static function that allocates it on first use. More importantly, don't bullshit yourself.

  • (cs) in reply to Smug Unix User
    Smug Unix User:
    if foo:
      DoSomething()
    else:
      CodingStandardsLib.NoOp()
    #snip....
    def CodingStandardsLib:
       """ This isn't a waste. Now you can add code to every else case. Think about a sleep or a wait here so you can instantly 'improve' application performance by decreasing the sleep amount. """
       return False
    

    Have the "do nothing" function call write a line to the console log. Something like "It's okay; Kendra killed the bad lamp."

  • (cs) in reply to Jay
    Jay:
    no laughing matter:
    The word root does not even exist in german language.
    So what does "root" mean in German? In what way is it sexist?
    As already written it does not even exist in the german language.

    It was considered sexist because it has a rude (pun intended) meaning in english slang and it would offend female readers having to constantly deal with such a dirty word (whose dirty meaning >99% never even heard about).

  • (cs) in reply to GoF
    GoF:
    Don't bullshit me about it by using a private static pointer that you retrieve with a public static function that allocates it on first use. More importantly, don't bullshit yourself.
    That is not a required feature for a singleton. The GoF used it to come around some C++-limitations in regards to order of initialisation of global objects (yes, they indeed call them "global objects") but in other languages singletons can be implemented without the "lazy initialisation" feature.
  • (cs) in reply to n_slash_a
    n_slash_a:
    No. That is why you delete the variable name. This way you keep the function signature but are specifically telling the compiler that one (or more) of the parameters are unused.
        void MyCallBack(int someNumber, aDate )
        {
            SomeImportantFunction(someNumber);
        }
    
    I think that will work in C++, but not in C. The C way will work in both C and C++.

    This is very language-dependent (and possibly compiler-dependent) behavior.

  • Rudyx (unregistered)

    Please don't blame me. Code written below is not mine.It was written against me.

    quite cute - yet another way to perform SQL injection !

  • distineo (unregistered) in reply to no laughing matter
    no laughing matter:
    It was considered sexist because it has a rude (pun intended) meaning in english slang and it would offend female readers having to constantly deal with such a dirty word (whose dirty meaning >99% never even heard about).
    Dirty != sexist Assuming that it's OK to be dirty around men but not women == sexist
  • M (unregistered)

    Am I the only one failing to see any WTF in the JVM error?

  • meh (unregistered) in reply to JamesCurran
    JamesCurran:
        void MyCallBack(int someNumber, aDate validDate)
        {
            SomeImportantFunction(someNumber);
        }
    
    Now, most compilers will give a warning, saying validDate is unused and can be removed. However, it can't be removed, as the framework is going to pass it when it call MyCallBack. So, they add the DoNothing function, just to keep the compiler thinking both parameters were used.
    What language are you working in?

    Most compilers will issue a warning (or an error) if there's an unused variable, but function parameters are not the same as variables, and I've never encountered a compiler, at least in C/C++, that gives a warning on an unused function parameter.

    In fact, most C ABIs will happily deal with a function that has fewer arguments, provided you cast it correctly.

  • meh (unregistered) in reply to DCRoss
    DCRoss:
    If only there was some sort of manual which could be the correct place to put documentation. Perhaps it could look something like this:
    $ man xxd <snip>

    Nah, it would never work. People would complain that the command name was sexist.

    Hardly. "man" produces output that's short, to the point, accurate yet often unhelpful, and without any regard for the feelings or frustration of the asker. Hmm... perhaps there's a stereotype in there...

    I would find it quite funny if someone wrote a command "woman" that took man's output and made it easier to use, or at least cross-referenced, searchable, and more useful than the horror that is "info".

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered) in reply to tin
    tin:
    It's not the language's fault that idiots with hammers will try to treat everything as a nail.
    But it is PHP's fault that it is a bad hammer. Oops, I guess I should've used php_real_hammer... or was it real_php_hammer?
  • Pythonidae (unregistered)

    python -c 'import binascii; print(binascii.unhexlify("506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E"))'

  • mi (unregistered)

    No need of Unix tools or PHP programs, I prefer to have decoded secrets printed on paper.

    %!PS-Adobe-2.0
    /input (506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E) def
    
    /table (0123456789ABCDEF0123456789abcdef) def
    /digitconv
    {
        input exch 1 getinterval 
        table exch search
        not {pop false exit} if
        length exch pop exch pop
        16 mod
        true
    } def
    
    /limit input length 2 idiv def
    /result limit string def
    0
    {
        dup limit ge {exit} if
        dup dup 2 mul dup 1 add
        digitconv not { exit } if
        exch
        digitconv not { exit } if
        4 bitshift or
        result 3 1 roll
        put
        1 add
    } loop
    
    result
    /Helvetica findfont
    10 scalefont setfont
    72 592 moveto
    show
    showpage
    
  • foo (unregistered) in reply to no laughing matter
    no laughing matter:
    GoF:
    Don't bullshit me about it by using a private static pointer that you retrieve with a public static function that allocates it on first use. More importantly, don't bullshit yourself.
    That is not a required feature for a singleton. The GoF used it to come around some C++-limitations in regards to order of initialisation of global objects (yes, they indeed call them "global objects") but in other languages singletons can be implemented without the "lazy initialisation" feature.
    Actually, lazy initialisation is the main reason I occasionally use singletons (in C++), either because of the above-mentioned global initialization order problem or if construction is expensive and the global/singleton is not (almost) always needed, e.g. in libraries. If neither reason applies, a plain global is much clearer indeed.
  • Cheong (unregistered)

    @Adam K.: I don't know if you've changed some of the bytes before posting, but hope you've done so.

    It's fairly common for programmers to write "intermediate result captured from production" down for debug and forgotten to remove them later. And if you're working in bank app it might contain condifential data of customers.

  • Bill C. (unregistered) in reply to pixel
    pixel:
    Reminds me of a function I found somewhere deep down in our code base:

    procedure DoNothingWithDate (const aDate: TDateTime) begin ; // do nothing end;

    And it was called like this:

    DoNothingWithDate (validDate); // Make compiler happy

    Fortunately I'm not that compiler. Happy doing nothing with a date... No, wait! That's what I should have told Starr!

  • faoileag (unregistered) in reply to Jay
    Jay:
    faoileag:
    But you can have OO and globals! No problem at all, the technique is called the "Singleton Pattern". It's in the book, so it must be ok to use ist! :-)
    Oh, here we go again.

    There seems to be a regular cycle in the IT business. We regularly go through conversations like this

    Stupid me for not using ;-) at the end of that sentence :-)

  • foo (unregistered) in reply to Cheong
    Cheong:
    @Adam K.: I don't know if you've changed some of the bytes before posting, but hope you've done so.
    No way to find out. Unless someone managed to decrypt this gibberish. But that seems quite impossible. Oh man, I really wanna know what it means. If only someone could tell us. But I guess I'm hoping in vain. If there was a tool readily available to decrypt it, no problem. Or if it could be done with a one-liner in any of various languages. Or at least if someone could write a few pages of complicated code to figure it out. But no, even if someone was going to do it, they certainly wouldn't post the results of their efforts in a comment section on a web site. No, it's hopeless ...
  • (cs) in reply to foo
    foo:
    Cheong:
    @Adam K.: I don't know if you've changed some of the bytes before posting, but hope you've done so.
    No way to find out. Unless someone managed to decrypt this gibberish. But that seems quite impossible. Oh man, I really wanna know what it means. If only someone could tell us. But I guess I'm hoping in vain. If there was a tool readily available to decrypt it, no problem. Or if it could be done with a one-liner in any of various languages. Or at least if someone could write a few pages of complicated code to figure it out. But no, even if someone was going to do it, they certainly wouldn't post the results of their efforts in a comment section on a web site. No, it's hopeless ...
    It's fairly common for programmers to write "intermediate code captured from production" down for comment in thedailywtf-forum or side-bar and forgotten to remove them later. And if you're working in bank app it might contain condifential data of customers. So to avoid seeing condifential data of bank customers, Cheong refuses to read any comments.
  • foo (unregistered) in reply to no laughing matter
    no laughing matter:
    foo:
    Cheong:
    @Adam K.: I don't know if you've changed some of the bytes before posting, but hope you've done so.
    No way to find out. Unless someone managed to decrypt this gibberish. But that seems quite impossible. Oh man, I really wanna know what it means. If only someone could tell us. But I guess I'm hoping in vain. If there was a tool readily available to decrypt it, no problem. Or if it could be done with a one-liner in any of various languages. Or at least if someone could write a few pages of complicated code to figure it out. But no, even if someone was going to do it, they certainly wouldn't post the results of their efforts in a comment section on a web site. No, it's hopeless ...
    It's fairly common for programmers to write "intermediate code captured from production" down for comment in thedailywtf-forum or side-bar and forgotten to remove them later. And if you're working in bank app it might contain condifential data of customers. So to avoid seeing condifential data of bank customers, Cheong refuses to read any comments.
    Good one! I just told it to Mr. Tim E. Smith of Chicago, IL, born Aug 15, 1970, when discussing his $75000 mortgage application. He found it very funny too, before I told him we'd have to refuse his application because of the $12495.35 balance on his credit card.
  • Dilligaf (unregistered) in reply to meh
    meh:
    DCRoss:
    If only there was some sort of manual which could be the correct place to put documentation. Perhaps it could look something like this:
    $ man xxd <snip>

    Nah, it would never work. People would complain that the command name was sexist.

    Hardly. "man" produces output that's short, to the point, accurate yet often unhelpful, and without any regard for the feelings or frustration of the asker. Hmm... perhaps there's a stereotype in there...

    I would find it quite funny if someone wrote a command "woman" that took man's output and made it easier to use, or at least cross-referenced, searchable, and more useful than the horror that is "info".

    Sounds like a great idea! Of course, for fully accurate performance the "woman" command would sometimes present a large amount of output that wasn't really related to anything in the man page at all - or, it would decide to present various arguments why some part of the man page was inaccurate, incorrect, and unacceptable.

    I'm sure you can think of other features.

  • anonymous (unregistered) in reply to mi
    mi:
    No need of Unix tools or PHP programs, I prefer to have decoded secrets printed on paper.
    %!PS-Adobe-2.0
    /input (506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E) def
    

    /table (0123456789ABCDEF0123456789abcdef) def /digitconv { input exch 1 getinterval table exch search not {pop false exit} if length exch pop exch pop 16 mod true } def

    /limit input length 2 idiv def /result limit string def 0 { dup limit ge {exit} if dup dup 2 mul dup 1 add digitconv not { exit } if exch digitconv not { exit } if 4 bitshift or result 3 1 roll put 1 add } loop

    result /Helvetica findfont 10 scalefont setfont 72 592 moveto show showpage

    Is it just me, or does that convert 27 into a right single quotation mark instead of an apostrophe?
  • anonymous (unregistered)

    Javascript:

    unescape("%"+("506C6561736520646F6E277420626C616D65206D652E20436F64" +"65207772697474656E2062656C6F77206973206E6F74206D696E" +"652E497420776173207772697474656E20616761696E7374206D" +"652E").match(/[\s\S]{2}/g).join("%"));

  • (cs) in reply to foo
    foo:
    Good one! I just told it to Mr. Tim E. Smith of Chicago, IL, born Aug 15, 1970, when discussing his $75000 mortgage application. He found it very funny too, before I told him we'd have to refuse his application because of the $12495.35 balance on his credit card.
    // Oh well, another mortgage. It's the accepted way around here apparently. The 08's called, they want their mortgage bubble back.
    extern ShadowBank *gShadowBank;
    
  • anonymous (unregistered)

    Groovy:

    groovy -e "println new String('506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E'.decodeHex())"

  • AN AMAZING CODER (unregistered) in reply to John
    John:
    I did once work on a project whose leaders thought that there was something wrong with an if that lacked its else, and the official coding standard required an else for every if

    I believe there are industries like Avionics that require this for compliance reasons, actually. Something to do with explicit clarity when reading the code. Someone with experience in that industry may want to speak to it further.

  • AN AMAZING CODER (unregistered) in reply to GoF
    GoF:
    Jay:
    faoileag:
    But you can have OO and globals! No problem at all, the technique is called the "Singleton Pattern". It's in the book, so it must be ok to use ist! :-)

    Oh, here we go again.

    There seems to be a regular cycle in the IT business. We regularly go through conversations like this:

    Astute person: Hey, X is being used in ways that cause trouble. We should think carefully before using X, and make sure that we only use it in those cases where it is appropriate and helpful.

    Simplistic person: You should never use X.

    Authoritarian person; As the experts agree that X is bad, we have established a standard that we will not allow the use of X in programs written by this company.

    Frustrated person: I can think of many cases where X is good. This is a stupid rule. There are some things that are very difficult to do WITHOUT using X.

    Other simplistic person: Yeah, Frustrated has shown that X isn't bad at all. We should use it for everything.

    The thing about the Singleton Pattern, though, is that you will find people who will honk on mightily about how great Singletons are who will then, in the same paragraph, talk about how bad global variables are, without realizing that a singleton IS a global variable, just one that's disguised enough to get through any set of coding standards that is asinine enough to ban globals for any use whatsoever.

    Like, there are a set of times when it makes sense to use a global. I get it. So, if you're damn sure it's one of those times, then go use a global. Don't bullshit me about it by using a private static pointer that you retrieve with a public static function that allocates it on first use. More importantly, don't bullshit yourself.

    I have to disagree slightly. Globals and Singletons aren't necessarily completely the same, depending on how the global is declared (and possibly the function).

    Usually a singleton does exactly what you described: You request it, if it exists it's returned, if not it's created. Typically you can't reassign the singleton once it exists (there's nothing stopping you from creating a method that reinitializes it, but that's outside of the singleton pattern). A global, I can reassign.

    I agree that banning globals outright is dumb, but it's certainly possible to have more protection over Singletons than globals.

  • anonymous (unregistered)

    More Javascript:

    "506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E".replace(/[\s\S]{2}/g, function(h){return String.fromCharCode(parseInt(h, 16))});

  • (cs) in reply to foo
    foo:
    Good one! I just told it to Mr. Tim E. Smith of Chicago, IL, born Aug 15, 1970, when discussing his $75000 mortgage application. He found it very funny too, before I told him we'd have to refuse his application because of the $12495.35 balance on his credit card.

    Geez, a $75,000 mortgage? You can't buy a doghouse around here for that little money. You would have to go to some desolate area in some silly state (to mention one would be telling) to have even half a chance to buy a piece of property.

    Then again, I hear that double-wide's are on sale these days. Good luck.

  • (cs) in reply to faoileag
    faoileag:
    Esse:
    I am indeed an IT professional. That is why I wrote a PHP script
    There are people who think that the highlighted terms are mutually exclusive, you know.

    Exactly. Those who write PHP and C++ are real software developers. All other languages = IT professional.

    Feel that burn! Oh yeah!

  • D8 (unregistered)

    Sometimes we must admit defeat. Sometimes a variable really is global. Like when it's actually used by every function in the program in a well-defined way.

  • qbolec (unregistered)

    location=" 506C6561736520646F6E277420626C616D65206D652E20436F64".match(/../g).join("%")

  • qbolec (unregistered) in reply to foo
    foo:
    JamesCurran:
    DoNothingWithDate (validDate); // Make compiler happy

    Functions like that are used in functions which are called by a framework, and hence the framework defines the called methods signature. So, we may have something like:

        void MyCallBack(int someNumber, aDate validDate)
        {
            SomeImportantFunction(someNumber);
        }
    

    Now, most compilers will give a warning, saying validDate is unused and can be removed. However, it can't be removed, as the framework is going to pass it when it call MyCallBack. So, they add the DoNothing function, just to keep the compiler thinking both parameters were used.

    But the DoNothing function doesn't actually use the parameter, so the compiler will give a warning, saying it is unused and can be removed. So, they add the DoNothing2 function, just to keep the compiler thinking the parameter was used.

    Nonsense, that would require an infinite number of functions. Instead you should use recursion! And since it is tail-recursive, it will be optimized away anyway.

  • 4e65696c (unregistered) in reply to anonymous
    616e6f6e796d6f7573:
    2f5b73535d7b327d2f67
    596f75206d696768742077616e7420746f206c696d697420796f7572207061747465726e20746f206d61746368696e672076616c6964207061697273206f6620686578206469676974732e
  • Mikey (unregistered) in reply to anonymous

    That seems like a lot of work, I just launched Visual Studio and wrote this in C#.

    var msg = "506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E";

    var output = "";

    for (int i = 0; i < msg.Length; i += 2) { var part = msg.Substring(i, 2); var c = (char)int.Parse(part, System.Globalization.NumberStyles.HexNumber); output += c; }

    Console.WriteLine(output);

    // It says: "Please don't blame me. Code written below is not mine.It was written against me."

  • Mikey (unregistered) in reply to qbolec

    I see what you did there... but it doesn't really work... at least not in chrome... it just navigates me to: "http://thedailywtf.com/Comments/5%06%C6V%176R%06F%F6%E2wB%06%26%C6%16%D6R%06%D6R%E2%046%F6" -- which doesn't load.

    Captcha: Delenit.

  • (cs) in reply to Mikey
    Mikey:
    I see what you did there... but it doesn't really work... at least not in chrome... it just navigates me to: "http://thedailywtf.com/Comments/5%06%C6V%176R%06F%F6%E2wB%06%26%C6%16%D6R%06%D6R%E2%046%F6" -- which doesn't load.
    It works if you have two spaces at the start of the string.
  • anonymous (unregistered) in reply to Kivi
    Kivi:
    Mikey:
    I see what you did there... but it doesn't really work... at least not in chrome... it just navigates me to: "http://thedailywtf.com/Comments/5%06%C6V%176R%06F%F6%E2wB%06%26%C6%16%D6R%06%D6R%E2%046%F6" -- which doesn't load.
    It works if you have two spaces at the start of the string.
    Firefox doesn't:

    location=" 506C6561736520646F6E277420626C616D65206D652E20436F64".match(/../g).join("%")

    If anybody would like to work on this bug, it has been open since 2001-12-19...

  • (cs)

    You're all mad. I just used TCL!

    % set cyphertext {506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E}
    506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E
    % for {set i 0} { $i < [string length $cyphertext] } { incr i 2 } {  
    set chr [string range $cyphertext $i [expr $i+1]]
    scan $chr %x hex              
    puts -nonewline [format %c  $hex]
    }
    Please don't blame me. Code written below is not mine.It was written against me.% 
    

    what a beautiful language.

  • Jimmy Hess (unregistered) in reply to anonymous

    Yawn

    echo -e $(echo '506C6561736520646F6E277420626C616D65206D652E20436F6465207772697474656E2062656C6F77206973206E6F74206D696E652E497420776173207772697474656E20616761696E7374206D652E' | perl -pe 's/([0-9A-F][0-9A-F])/\x$1/g')

Leave a comment on “Comments, Errors, and Log Messages...OH MY!”

Log In or post as a guest

Replying to comment #:

« Return to Article