• Buddy (unregistered) in reply to the real wtf fool
    the real wtf fool:
    Since when was bool(ean) a 'first-class' type in C??

    C99

  • (cs) in reply to Buddy
    Buddy:
    the real wtf fool:
    Since when was bool(ean) a 'first-class' type in C??

    C99

    That's just some poxy newcomer. ANSI C FTW.

  • (cs) in reply to Zylon
    Zylon:
    Aaron:
    Zylon:
    If I'm testing for truth, I'll do "if (value)", but for the opposite, yeah, I'll do "if (value == false)", simply because it makes the code easier to read than using the ! operator.
    TRWTF.

    One of the most common conditions you have to test for in any high-level language is null-inequality. Are you saying that every single time you do this, you'll waste time trying to "refactor" code that's perfectly fine, or change it into an if-then-else with an empty if block?

    I'm not testing for "null-inequality", you trolling halfwit, I'm testing for FALSE. It's a boolean, gettit?
    Even if your aversion to the "!" operator only applies to simple single-order conditionals (which wasn't clear at all), it's still idiotic. Another very common test is
    if (!string.IsNullOrEmpty(s)) { ... }
    What do you propose, putting a line before every single one of these tests?
    bool sHasValue = !string.IsNullOrEmpty(s);
    ...which not only adds needless clutter but also isn't really any easier to read or harder mess up (you can still forget the "!"). Or perhaps you like to write it as
    if (string.IsNullOrEmpty(s) == false) { ... }
    Yeah, that's MUCH more readable!

    Or, wait, let me guess, you added some pointless non-standard extension method to the string class ("IsNotNullOrEmpty") and use that everywhere, confusing and infuriating everyone who doesn't know where the method is declared in order to enforce some nebulous idea of "readability" that only you understand?

    You're awfully belligerent for such a nitwit. It seems like every post you make is thick on opinions and thin on facts.

  • C (unregistered) in reply to Lee K-T
    Lee K-T:
    Daid:
    I have seen worse:

    if((!notShouldContinue) == false)

    Good luck.

    This is not a copy-past so it might not be 100% the same (I think one of the cases was missing actually, lol). Anyway here's what I've found:

    bool var1 = ...; bool var2;

    if (true == true) { // code that does var2 = var1 } else if (false == false) { // code that does var2 = var1 again! }

    Are you serious about that "T == T, elif F == F"?!?

    Also, how does your code relate to the post you quoted?

  • (cs) in reply to the real wtf fool
    the real wtf fool:
    Buddy:
    the real wtf fool:
    Since when was bool(ean) a 'first-class' type in C??

    C99

    That's just some poxy newcomer. ANSI C FTW.

    C99 *is* ANSI C. You should have said K'n'R.
  • minime (unregistered) in reply to No Particular Order
    No Particular Order:
    Billant ... NOT
    Lern 2 splel.
  • (cs) in reply to DaveK
    DaveK:
    the real wtf fool:
    Buddy:
    the real wtf fool:
    Since when was bool(ean) a 'first-class' type in C??

    C99

    That's just some poxy newcomer. ANSI C FTW.

    C99 *is* ANSI C. You should have said K'n'R.

    ANSI C is C89/90. K&R predates that and is so damn forgiving with parameters etc. that it drives me nuts.

  • Gerrit (unregistered) in reply to the real wtf fool
    the real wtf fool:
    Gerrit:
    Or they learned the trade using COBOL or some other language very unlike C.

    Since when was bool(ean) a 'first-class' type in C??

    Sorry for being unclear. I was thinking of languages with a C-like syntax, not about C specifically.

  • sota (unregistered)

    At the previous developer I worked for, most objects had a SetEnabled() method that accepted a bool as the single parameter. The method also returned a bool indicating whether or not the object was successfully enabled.

    It led to fun code like this:

    if (!Neighbor.SetEnabled(!Enemy.SetEnabled(false))
    {
    ...
    }
    

    It became second nature to read it after a while, but it still drives me nuts.

  • (cs) in reply to Geoffey Sturdy
    Geoffey Sturdy:
    DaveK

    "Bollocks. Making fun of anyone is OK, we have this thing called freedom of speech.

    Most Christians and Muslims can take a joke too. And Jewish humour is legendary for its self-deprecating nature.

    It's only saddos like you who go around saying people "should be punished" for not thinking the exact same way as you do"

    Not in the UK You can be arrested for "hate crinmes" for making jokes about Blacks Gays Muslims

    but not apparently Christians or Jews

    What a bunch of self-pitying whingeing horse shit. Yes, you can be arrested for anything or nothing at any time, that's how the police work, but it's not against the law to be rude to people and thank fuck we have a legal system that says they have to charge you promptly or let you go, even though those bastards have been kicking holes in all our rights for the past few years we still actually possess most of them. Let's face it, you don't know what you're talking about - this hasn't ever happened to you or anyone you know, you're just repeating at third hand some half-remembered mangled version of an old news story that probably has no more truth to it than all the old made-up stuff about them banning curved bananas and stuff.
    Geoffey Sturdy:
    in a country where a mother wih a disabled daughter can commit suicide after bieng terrorised by thugs and the police simply saying "close your curtains and pretend they arn't there" and yet a Christian couple can be arrested for Arguing with amuslim about religion .
    Now you're just on planet fucking looney. WTF do any of these random and unrelated things have to do with anything at all in the whole world except for your overblown sense of entitlement and massive chip on your shoulder?
  • Call me crazy but... (unregistered)

    ... I just can't believe this isn't a fake.

  • Burpy (unregistered) in reply to Call me crazy but...
    Call me crazy but...:
    ... I just can't believe this isn't a fake.
    You must be kidding, it happens all the time!?! These boolean rapes are the most common codes in the whole universe.
  • El Dorko (unregistered) in reply to bob

    ""Wow, what a complete dorko. "

    I've never felt compelled to comment before but I have to agree.

    What a complete dorko."

    It's all in a name! Anyway, I feel much better today after having adjusted the medication. Cheers!

  • (cs) in reply to the real wtf fool
    the real wtf fool:
    DaveK:
    the real wtf fool:
    Buddy:
    the real wtf fool:
    Since when was bool(ean) a 'first-class' type in C??

    C99

    That's just some poxy newcomer. ANSI C FTW.

    C99 *is* ANSI C. You should have said K'n'R.

    ANSI C is C89/90.

    C99 is the latest ANSI standard in the series that began with C89 and C90. All three are "ANSI C".
    the real wtf fool:
    K&R predates that and is so damn forgiving with parameters etc. that it drives me nuts.
    It's also the only C language standard there is that isn't "ANSI C".
  • (cs) in reply to Capulet
    Capulet:
    SkUrRiEr:
    That's nothing, the coders who originally wrote the software I'm hacking have an insane love for code that looks like this:
    $variable = $_REQUEST["param"]?$_REQUEST["param"]:0;
    What is so insane about that? I've looked through your original post backwards and forward, and I can't figure out why this is biting your arse. Do you have a problem with ternary operations?

    You could do:

    $variable = 0;
    if( $_REQUEST['param'] ){
    $variable = $_REQUEST['param'];
    }
    but that's just a lot more verbose.

    The slight WTF is that PHP's boolean operators - unlike in C - actually only return booleans. So:

    $variable = $_REQUEST['param'] || 0;
    // $variable will always be either True or False

    I'm with Capulet, I don't understand what's so wrong about

    $variable = $_REQUEST["param"]?$_REQUEST["param"]:0;
    .

  • highphilosopher (unregistered) in reply to Anon
    Anon:
    bool:
    Where do people learn that they should compare booleans to the value of true.

    I see people around me doing it. I don't get it. I've never compare a boolean, only test it.

    In C# if you are using a bool? (nullable bool), you would need to compare it to true since it could be true, false or null.

    i.e.

    if (nullableBool)

    doesn't compile because nullableBool isn't a bool.

    Of course, this isn't the case here, but it could be a habit.

    NULLABLE BOOLS SHOULD BE SHOT!!!!!!!!!!!!

  • Lee K-T (unregistered) in reply to highphilosopher
    highphilosopher:
    Anon:
    bool:
    Where do people learn that they should compare booleans to the value of true.

    I see people around me doing it. I don't get it. I've never compare a boolean, only test it.

    In C# if you are using a bool? (nullable bool), you would need to compare it to true since it could be true, false or null.

    i.e.

    if (nullableBool)

    doesn't compile because nullableBool isn't a bool.

    Of course, this isn't the case here, but it could be a habit.

    NULLABLE BOOLS SHOULD BE SHOT!!!!!!!!!!!!

    Quite true. It's silly 'cause I don't really have the choice but, as a C# developer, each time I have to use var=true I feel guilty and I end up writing a bunch of lines to explain why I commited such felony. :)

    captcha: wisi. seems like someone lost his wig...

  • (cs) in reply to NightDweller
    NightDweller:
    Personally i find this (value==false) to be aesthetically unappealing. its a worthwhile habit to have if you code in c/c++ where the if checks against zero values. in which case it would probably be a good idea to also do the (value==true) side.

    Sorry, are you saying comparing against true / false is advisable in C++?? I don't see why. In fact I can show you a case where comparing a bool against true may not do what one would expect, whereas just testing works fine.

    #include <iostream>

    int main() { bool b = false; unsigned char* p = reinterpret_cast < unsigned char* > ( &b );

    *p = 6;
    
    if ( b == true )
    {
    	std::wcout << L"b does not equal true\n";
    }
    else
    {
    	std::wcout << L"b does not equal true\n";
    }
    
    if ( b )
    {
    	std::wcout << L"b evaluates to true\n";
    }
    else
    {
    	std::wcout << L"b evaluates to false\n";
    }
    
    return 0;
    

    }

    Using Visual C++ 2008 this prints: b does not equal true b evaluates to true

    Addendum (2009-10-09 14:39): Meh, I fucked up my code sample. Should have been:

    #include <iostream>

    int main() { bool b = false; unsigned char* p = reinterpret_cast < unsigned char* > ( &b );

    *p = 6;
    
    if ( b == true )
    {
    	std::wcout << L"b does equals true\n";
    }
    else
    {
    	std::wcout << L"b does not equal true\n";
    }
    
    if ( b )
    {
    	std::wcout << L"b evaluates to true\n";
    }
    else
    {
    	std::wcout << L"b evaluates to false\n";
    }
    
    return 0;
    

    }

    Sorry.

  • www.pretty-tiffany.com (unregistered)

    Thank you for your sharing,I like this.

  • www.happytiffany.com (unregistered)

    Beautiful you are, I believe would like tiffany jewelry

  • Fregas (unregistered)

    the comment on scientology is the money shot

  • BAF (unregistered) in reply to !?
    The fool! He needs another if!

    ///

    /// Turns true into false and false into true /// -- similar to the church of scientology. /// <param name="_booInpt">True of false</param> /// <returns>False or true</returns> private bool trueandorfalse(bool _booInpt) { // I'm quite sure though there is a very // clever C# standard command doing this, // I just can't find it right now ... if (_booInpt == true) return false; if (_booInpt == false) return true; }

    Looks like I caught this one just in time! :)

    Don't you mean:

    /// 
    /// Turns true into false and false into true 
    ///   -- similar to the church of scientology.
    /// <param name="_booInpt">True of false</param>
    /// <returns>False or true</returns>
    private bool trueandorfalse(bool _booInpt)
    {
        // I'm quite sure though there is a very 
        // clever C# standard command doing this, 
        // I just can't find it right now ...
        if (_booInpt == true)
            return false;
        if(trueandorfalse(_booInpt) == true)
            return true;
    }
    
  • Eponymous Coward (unregistered) in reply to Shredder

    XML is like violence: if it isn't working, you aren't using enough of it.

  • scott (unregistered) in reply to Gerrit

    I cant say if this is the case....

    I've been known to throw in stupid statements like this for debugging when I want to set a break point in debug mode.

  • Bryan W (unregistered)

    Just this week, one of my fellow "developers" asked if there was some clever function that would easily reverse the sign on a number, like change a negative to a positive and a positive to a negative. I told him to put a "-" in front of it, and he looked confused. So I told him to multiple by -1, he thought for 10 seconds, then admitted this was really "clever".

  • me (unregistered)

    return ( _booInpt ) ? false : true;

  • (cs)

    seems like this clever uncle is way past retirement age?

  • (cs) in reply to Steve

    // Oh noooo! !!!smart;

  • (cs) in reply to Anon

    WTF #4 is not allocating memory

Leave a comment on “The Clever Coder”

Log In or post as a guest

Replying to comment #:

« Return to Article