• Dot (unregistered)

    Zreoth!

  • Jon (unregistered)

    I really need a t-shirt that just says TRWTF===PHP

  • (nodebb)

    The thinking capacity this developer demonstrated while fixing this bug is in line with the age zero, and emptiness is what's in his head.

  • Officer Johnny Holzkopf (unregistered)

    It's probably not the frist time we see this kind of "bug fixing": When a conditional, loop, abort trap or comparison leads to the expected result ALMOST every time, but not EVERY time, the obvious solution is to add an inversion of the conditional, increase or decrease a loop counter's end value by 1, add another exception (to be ignored), or change the direction of a comparison. It is also possible to combine those methods for more advanced "bug fixing", typically used by experensed programers and certified consultends like Paula.

  • (nodebb)

    Maybe the original devs were from East Asia, where certain countries there start age counting at age 1 from the day of birth.

  • (nodebb)

    if ( ! frist(comment) || frist(comment)) then frist

    ??

  • Shakespeare (unregistered)

    To be or not to be, that is the question...

  • (nodebb)

    Presumably the correct fix is something like this:

       if ( isset($_POST["age_at_time"]) && $_POST["age_at_time"] >= 0 )
       {
          // handle OK case
          ...
       }
       else
       {
          // handle not-OK case
          ...
       }
    
  • (nodebb) in reply to Steve_The_Cynic

    Steve, you're no fun Or is that 0 fun?
    or NULL fun?

  • (nodebb) in reply to Steve_The_Cynic

    Surely the correct fix is not to use PHP?

  • (nodebb)

    ISTM the correct fix is to actually have requirements.

  • xtal256 (unregistered)

    "child ages are zero-indexed"

    No, they are not. Age is a count (of years), not an index.

  • LZ79LRU (unregistered)

    The real WTF here is PHP and all languages that have insane concepts like "falsy".

  • (nodebb)

    Oldest programming WTF ever

    if (to(b) || !to(b))
    {
        that = the[question];
    }
    
  • (nodebb) in reply to xtal256

    Age is a count (of years), not an index

    At Jeremyp's Nurseries (affiliated with the Hilbert Hotel chain) the rooms are numbered from zero and each child is placed in the room whose number corresponds to their age in years. So, yes, actually, age is an index.

  • Loren Pechtel (unregistered)

    It's not alone. I hit a BMI calculator that insisted I couldn't be 0 inches tall. Thus I had to shrink from 6'0" to 5'12".

  • (nodebb) in reply to LZ79LRU

    The real WTF here is PHP and all languages that have insane concepts like "falsy".

    I was rather surprised that the introduction of booleans to Python at one point was a PEP, and not very popular at that, because "integers already do that".

    I wonder where along the line the mindset changed enough to allow the introduction of pathlib, because after all, strings already do that.

  • Anonymous (unregistered) in reply to Steve_The_Cynic

    PHP has a handy function for validating integers:

    $age_at_time = filter_var(
        $_POST['age_at_time'] ?? '',
        FILTER_VALIDATE_INT,
        ['options' => ['min_range' => 0]]
    );
    if ($age_at_time === false) {
        die('Invalid age.');
    }
    
  • (nodebb) in reply to LZ79LRU

    The real WTF here is PHP and all languages that have insane concepts like "falsy".

    But where's the fun in that? Languages like PHP or JavaScript which have wild interpretations of trueiness and falsiness are great, and are perfect candidates for WAT slideshows filled with rubber duckies.

  • Craig (unregistered) in reply to LZ79LRU

    The real WTF here is that the language's "empty" function returns true for things that aren't empty.

  • (nodebb)

    Ran into a nice example today for the "falsy/truthy" issue, and why Python really still is not explicit enough about it.

    if not path.exists:
        continue
    

    Always truthy. Also, given that path.exists might as well be a property invoking a getter, this is easy to mix up in Python.

    So really, a nice example why Python should accept only booleans as booleans... But that would severely break backwards compatibility.

    Python4 anyone? :)

Leave a comment on “Empty Reasoning”

Log In or post as a guest

Replying to comment #:

« Return to Article