• Nagesh (unregistered) in reply to dkf
    dkf:
    cellocgw:
    Dates are not "complex" structures. They're purely reals. Or strings.
    Dates are fruit that grow on date palms.
    Married programmer is only having to date palm one week per month.
  • Meep (unregistered) in reply to Herwig
    Herwig:
    This was my favorite:
    #define true 0
    ...the original author works now as chief developer for an Austrian company which codes software for medical healthcare...
    Say you have a main function in C:
    int main(void) {
      return stuff_worked() ? true : false;
    }
    

    What should true and false be, if we want to be compliant with standard exit codes?

    In bash, try:

    ( exit 34 ); echo $?
    true; echo $?
    false; echo $?
    true && echo yes, that worked
    false || echo nope, that failed
    
  • Trolleh (unregistered) in reply to D-Coder

    FTFTFY: This Yoda's head explode would make.

  • vt_mruhlin (unregistered)

    My favorite bool WTF was the guy who made a java program with two static AtomicBooleans, FileReader.TRUE and FileReader.FALSE. Everywhere throughout the code, he would do a reference comparison between a given bool and either FileReader.TRUE and FileReader.FALSE.

    The general idea was that there would be multiple kinds of readers, but this guy only implemented the FileReader, then passed it on to me for the rest. So I did some quick refactoring and quickly found that things were failing because SQLReader.TRUE != FileReader.TRUE

    I went and asked the guy WTF he was doing and had the most awkward "you're not getting it" conversation ever when he kept trying to tell me that he did it that way because "it has to be atomic".

  • Jonathan (unregistered)

    lol I like the hidden Cornify :) (click on "truth truly is ," on one of the last paragraphs... you won't be disappointed)

  • Worf (unregistered) in reply to Antti Alien
    Antti Alien:
    TRUE, FALSE, UNDEF, SIM

    In some situations that is completely sensible. In a hardware simulator, for example. Verilog uses four state logic:

    • 1 for true,
    • 0 for false,
    • Z for high-impedance state of an unconnected input, and
    • X for unknown.

    That's not enough to resolve all the possible states...

    There's also weak pull up/down, strong pull up/down as well. As well as open-collector/open-drain.

    Otherwise you can't simulate some logic, like say, USB.

    (USB uses weak pullups on the host - the stronger pulldowns on the device give determination between USB slow speed and USB full speed. High speed is negotiated through some special signalling during enumeration (chirps), and super speed well, probably uses the other pins.

    But having logic tied together means the logic has to take into account any pullups and pulldowns to resolve. (And yes, "driven" will override any pullup/pulldown, and a strong pull up/down will override a weak pull down/up, respectively).

  • M.L. (unregistered)
    TRUE, FALSE, UNDEF, SIM
    Maybe the author was preparing his code for quantum computing. SIM = simultaneous (true and false)
  • Captain Boolean (unregistered) in reply to Julia

    Invoice for new keyboard in the post!

    Captcha: Paratus, Even almighty!

  • (cs) in reply to Julia
    Julia:
    Ah, the age old problem...

    "Pilate saith unto him, What is truth? And when he had said this, he went out again unto the Jews, and saith unto them, I find in him no file at all."

    So be IT.

  • true_Ouch_false (unregistered)

    if (x == false) {x = true};

    This can actually save cycles and bandwidth: Say you have x in your desktop box but setting x is logged at the server. Fhen, if you set x, you'll have to wait until the server logs "User set x to true" and tells your box that it did. Checking if x isn't already true takes place in your box, which takes only nanoseconds or less. Setting x to true adds network traffic and a wait which is usually some microseconds, if not milliseconds. Depending on your environment, it may be better to avoid as many logged actions as possible. /* If you have to check for performance reasons, it always deserves a comment - / / or some other coder will rewrite it and bottleneck the LAN eventually */

    if (a) foo(a); else foo(a);

    I must confess that I wrote that code twice. Once, it survived for weeks, the other one more like ten minutes. (Decent compilers detect that kind of waste and compile foo(a); anyway) The old code used to be

    if (a) foo_nonzero(a); else foozero(a);

    Both times, the old foo_nonzero() had been improved to handle zero, thus eliminating the need for foo_zero. So, I'd say that an if (a) foo(a); else foo(a); is not a WTF. It's an artifact of old code. Unless it's in new code. Then it IS a WTF.

    About x.isTrue() and all the "boolean" silliness, some of them are less silly if they imply a type cast to boolean. However, type-casting is a WTF waiting to happen /* if it's not documented */

    Capcha: causa. As in, "I code in VB, causa fucked up manager duzn't allow any real language"

Leave a comment on “Truth or Sim”

Log In or post as a guest

Replying to comment #:

« Return to Article