Classic WTF: What Is Truth?

« Return to Article
  • Denis Troller 2007-12-24 08:32
    Sometimes, after many uses of the "FileNotFound" in comments, it seems like a distant funny mermory.

    But when I read it again, the insanity strikes me in full (goggles and all).
  • ObiWayneKenobi 2007-12-24 08:50
    As it was then, so it is now and forever: "My eyes! The goggles do nothing!"
  • erKURITA 2007-12-24 08:54
    Are you sure that dude isn't the same that "invented" the Nullity?
  • PyroTyger 2007-12-24 09:28
    Barely related, forgive me...

    I remember marking test-papers for a particularly obtuse and unoriginal A-level Philosophy teacher. He had posed the classic question (and oh! how my ribs ached): "Is this a question?"
    There were several answers along the lines of "Yes", "No" or "Only if this is an answer". The only one that made me laugh was:
    "Are you trying to be clever?"

    The only one that got full marks was:
    "I don't know!!!"
  • DoggettCK 2007-12-24 10:27
    We've got an object in our codebase called "Tri", which can be either True, False, or Null.

    I'd yank it out, but the lead insists it's necessary since a BIT field in our schema can potentially be null. Couldn't just set it to NOT NULL, no sir.

    So, for now, it'll just have to drive me slowly insane.
  • Flow 2007-12-24 10:40
    Doesn't use SQL some kind of ternary logic?
    true, false and unkown?
  • powerlord 2007-12-24 11:58
    Flow:
    Doesn't use SQL some kind of ternary logic?
    true, false and unkown?


    Yes, if you forget to declare a BOOLEAN column NOT NULL.
  • Just Some Guy 2007-12-24 12:06
    ...or if you do it on purpose. NULL is distinctly different from true/false.
  • Hans 2007-12-24 12:10
    Even allowing for ternary logic, it *really* sucks to invert truth values. Consider:

    bool x = true;
    if (x) { ...do something... }

    stupidbool y = stupidtrue;
    if (y) { ...doesn't work as expected... }

  • DarkSprout 2007-12-24 12:15
    Triple State is NOT a world of fun, I'm a Access Database administrator, so, I know...

    I'm afraid -- it makes perfect sense.
  • Sandy Claws 2007-12-24 12:54
    Saying something is a 3rd state is very different from saying it is an unknown. Sometimes you want to know if it isn't known.

    "..as we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns - the ones we don't know we don't know"

    :D
  • imtruth 2007-12-24 12:57
    so, in the enum, doesn't true = 0? that's messed up!
  • zellius 2007-12-24 13:10
    I've done something similar in one of my internships recently. When the user is updating his preferences, I keep track of the checkboxes by using TriStateBools: it is set to UNCHANGED by default indicating that the user didn't touch it, so it doesn't need to be updated.

    Is that a bad way to do it? How would you do it?
  • Manos 2007-12-24 13:31
    True has value 0, and a Bool with 3 possible values.
    I have been here before.
  • Disco Stu 2007-12-24 13:45
    DarkSprout:
    Triple State is NOT a world of fun, I'm a Access Database administrator, so, I know...

    I'm afraid -- it makes perfect sense.


    Access is a database?
  • Chris 2007-12-24 13:48
    You left out the four-fold state of existence according to Buddhist philosophy:

    enum Bool {
    True,
    False,
    BothTrueAndFalse,
    NeitherTrueNorFalse
    }

    I guess that FNF is equivalent to "neither nor", but it's sometimes nice to have both at the same time, too.
  • XPav 2007-12-24 16:49
    I really think that we need to add a comment or another value saying that we can't determine true or false until the wave function collapses.
  • saudade 2007-12-24 17:56
    Xpav: How about this then?
    http://www.perl.com/pub/a/2001/08/08/quantum.html

    Quantum::Entanglement, a classic perl module that made true and false... less than useful. :)

    Quantum::Superpositions was also a hoot, and actually useful.

    If you are going to mess with peoples heads, at least implement something like the entanglement module and enforce observation of the value behavior.

    Then it could be true, false, or any combination of that from 0 to 1! How fun could that be? Think of educating the users.

    User: When I try to save my document sometimes it never saves or only partially saves, why is that?
    You: Well, you see we implemented a quantum mechanics behavior in our code. When you go to save your document we collapse a running wave function to determine the state your document may or may not be saved in. In fact it could partially be saved or partially not saved. You will never truly know until you try to re-open it. Even then you never know exactly what will be loaded due to opening it being an observation of its state.

    Ah the fun you could have, hell just do it and don't tell anyone and watch debugging sessions turn into watching grown men cry because true isn't true and false isn't false, or even true can be false, and false can be true. It would be like real world, with programmers, and quantum mechanics. I need to start marketing some of these ideas to Hollywood.

    Disclaimer: The prior post may or may not be meant in good humor, you decide by collapsing the comment into a decision of my intentions which inevitably will cause my intentions to change their state. Isn't this FUN?!
  • null 2007-12-24 19:13
    Does a company exist that uses Access to the level that they need a dedicated administrator? Might be time to take the training wheels off...
  • Schroedinger 2007-12-24 22:13
    $ cat is_alive
    cat: is_alive: filenotfound
    $
  • ewww 2007-12-24 23:44
    zellius:
    I've done something similar in one of my internships recently. When the user is updating his preferences, I keep track of the checkboxes by using TriStateBools: it is set to UNCHANGED by default indicating that the user didn't touch it, so it doesn't need to be updated.

    Is that a bad way to do it? How would you do it?


    I would probably use two "normal" bools; one for changed/unchanged and another for true/false (only used when the other bool is set to changed).
  • Watson 2007-12-25 04:38
    Chris:
    You left out the four-fold state of existence according to Buddhist philosophy:

    enum Bool {
    True,
    False,
    BothTrueAndFalse,
    NeitherTrueNorFalse
    }

    I guess that FNF is equivalent to "neither nor", but it's sometimes nice to have both at the same time, too.


    Ah, that just looks like a set of booleans. It makes sense if you do something like BothTrueAndFalse=={True,False} while NeitherTrueNorFalse=={} and operations over booleans are extended to sets of booleans in the natural way (can't find the forum thread on Fortress's BooleanInterval type).
  • captain obvious 2007-12-25 05:38
    Disco Stu:
    DarkSprout:
    Triple State is NOT a world of fun, I'm a Access Database administrator, so, I know...

    I'm afraid -- it makes perfect sense.


    Access is a database?

    Are you two related by any chance?
  • jspenguin 2007-12-25 18:42
    I actually used this in a project once:

    http://www.jspenguin.org/dvdfs/dvdfs.c
  • Schroedinger 2007-12-25 19:39
    jspenguin:
    I actually used this in a project once:
    http://www.jspenguin.org/dvdfs/dvdfs.c
    That's not a use, that's an abuse! A function is_file() could use it properly, but a function is_directory() has to return DirectoryNotFound.

    If you don't fix it, you'll have to answer to me, upon which you'll be NeitherFoundNorNotFound.
  • Daniel Beardsmore 2007-12-25 19:40
    jspenguin:
    I actually used this in a project once:

    http://www.jspenguin.org/dvdfs/dvdfs.c


    LOL. That's twisted.
  • Paula 2007-12-26 01:13
    brillant.
  • Microsoft? 2007-12-26 02:13
    http://msdn2.microsoft.com/en-us/library/bb384091.aspx
  • KattMan 2007-12-26 09:13
    Microsoft?:
    http://msdn2.microsoft.com/en-us/library/bb384091.aspx


    Sadly, by creating the bool?, they are propogating the misuse and misunderstanding of bool.

    Bool is two state and only ever two state. If you can have null it is not a bool but rather a three state enum. Yes you can have a boolean in a database with no value but that non-value should be safely assumed to be one state or the other, such as a confirmed field, it is either confirmed or not, if the value has not been entered then it is not confirmed so it is false, safely assumed one value and continue. If you can not safely assume one value, then you do not have a bool and you will always be wrong when you try to implement it as a bool. Use an emun in those cases, because eventually you may expand to a fourth state or beyond.
  • FredSaw 2007-12-26 10:30
    zellius:
    I've done something similar in one of my internships recently. When the user is updating his preferences, I keep track of the checkboxes by using TriStateBools: it is set to UNCHANGED by default indicating that the user didn't touch it, so it doesn't need to be updated.

    Is that a bad way to do it? How would you do it?
    What you have there is the functional equivalent of an IsDirty property. I guess it depends on the scope of your project and how enterprisey and/or OOPy you want to get. You could have a collection of objects, each corresponding to one of your input controls, which are updated (and its IsDirty property set to true) whenever the value of the control changes. For persisting the data you would call the collection's Save method which in turn would iterate through the objects looking for IsDirty and saving the contained values (which would simply involve calling the object's own Save routine).

    As I say, if the scope is big enough... if you want to go all OOPy on your project.
  • distineo 2007-12-26 11:04

    function get_permitted(dirname, action)
    foo = read_permission_file(dirname . "/permissions.txt", action)
    if foo == file_not_found then
    return get_permissions(dirname . "/..")
    else
    return foo
    end
    end
  • dkf 2007-12-26 12:52
    KattMan:
    Bool is two state and only ever two state.
    Only in conventional boolean logic. Quite apart from idiocies like this WTF, there are real cases when analysing programs where a multi-valued logic is useful. There are two general types of analysis cases, one where you have an additional value that is approximately "none of the above" (great for checking code reachability IIRC) and the other which is "all of the above" (for code safety). That then reduces real programs (in a provably-safe way) to the point where they're tractable enough to model check.

    OK, in reality you have the power-set of the original values and some very interesting relations when you do program analysis over non-trivial datatypes. Automatically deriving the extended meaning of functions is particularly "interesting". But it's easier than the alternative.

    But calling a non-boolean type Bool... now that's nasty.
  • KattMan 2007-12-26 13:56
    dkf:
    KattMan:
    Bool is two state and only ever two state.
    Only in conventional boolean logic. Quite apart from idiocies like this WTF, there are real cases when analysing programs where a multi-valued logic is useful. There are two general types of analysis cases, one where you have an additional value that is approximately "none of the above" (great for checking code reachability IIRC) and the other which is "all of the above" (for code safety). That then reduces real programs (in a provably-safe way) to the point where they're tractable enough to model check.


    And I would argue that in your example you do not have a bool. You have a enum with 3 or more states. As I stated before, if you can not definitivly say yes/no or true/false then you do not have a bool, you have an enumerator that can possibly have more than one state.

    For example:
    A bool named confirmed, it either is confirmed or it is not. If it is not initialized then you can safely assume it is not.
    A bool named bagtype in a system that supposedly only supports paper and plastic. You would think that it is safe to have a bool, but it is not. Your values do not say yes/no they say paper/plastic. Yes it is only two state but if it is not filled in, if it is not initialized, you can not safely assume one or the other, this gives you a third state, unknown. You now have a tri-state value, this is an enum. You can always expand to four or more later if the system starts supporting other bag types such as cloth. Make this an enumerator from the beginning, do not try to force a boolean to accommodate poor planning.
  • Skronk 2007-12-26 21:46
    You mean there is no determinate value until the system crashes ?
  • Dana 2007-12-27 11:33
    Even worse, there's the humor language Java2k http://www.p-nand-q.com/humor/programming_languages/java2k.html in which functions only have a certain *probability* of doing what you expect..

    And it has a base 11 number system, go figure.
  • Tom_fan_DK 2007-12-28 06:02
    captain obvious:
    Disco Stu:
    DarkSprout:
    Triple State is NOT a world of fun, I'm a Access Database administrator, so, I know...

    I'm afraid -- it makes perfect sense.


    Access is a database?

    Are you two related by any chance?


    Are you related with the first one by any chance? The question "Access is a database?" makes perfect sense to the rest of the world ;-)
  • clively 2007-12-28 12:39
    KattMan:
    dkf:
    KattMan:
    Bool is two state and only ever two state.
    Only in conventional boolean logic. Quite apart from idiocies like this WTF, there are real cases when analysing programs where a multi-valued logic is useful. There are two general types of analysis cases, one where you have an additional value that is approximately "none of the above" (great for checking code reachability IIRC) and the other which is "all of the above" (for code safety). That then reduces real programs (in a provably-safe way) to the point where they're tractable enough to model check.


    And I would argue that in your example you do not have a bool. You have a enum with 3 or more states.


    Have you always had trouble reading or is it really just ADD kicking in.
  • foo 2007-12-29 14:52
    Schroedinger:
    $ cat is_alive
    cat: is_alive: filenotfound
    $

    best comment ever
  • Peb0 2008-01-04 12:53
    clively:
    KattMan:
    dkf:
    KattMan:
    Bool is two state and only ever two state.
    Only in conventional boolean logic. Quite apart from idiocies like this WTF, there are real cases when analysing programs where a multi-valued logic is useful. There are two general types of analysis cases, one where you have an additional value that is approximately "none of the above" (great for checking code reachability IIRC) and the other which is "all of the above" (for code safety). That then reduces real programs (in a provably-safe way) to the point where they're tractable enough to model check.


    And I would argue that in your example you do not have a bool. You have a enum with 3 or more states.


    Have you always had trouble reading or is it really just ADD kicking in.


    I see this the same way... it's simply not a boolean.

    The only WTF is in the name of the enum.
    Calling it "bool" seems to have run most of you up the wrong tree.

    What if it was renamed like...

    enum FileSizeGreaterThanOneGig
    {
    True,
    False,
    FileNotFound
    };


    It's just badly named.
  • 3.14159265358 2008-01-06 23:54
    Qubits anyone?
    enum QuantumBool {
    True,
    False,
    BothTrueAndFalse,
    NeitherTrueNorFalse,
    BetweenTrueAndFalse,
    GreaterThanTrue,
    LessThanFalse
    }
  • Jared Parsons 2008-01-08 15:57
    It has to have been a year since I first read this WTF and it still makes me double over laughing.

    Jared
    http://blogs.msdn.com/jaredpar
  • thAAAnos 2008-02-20 07:39
    XPav:
    I really think that we need to add a comment or another value saying that we can't determine true or false until the wave function collapses.


    also we need a value for current universe index.
  • dave 2010-01-05 17:38
    the real WTF is, that 0 will be assigned to true and 1 to false!
  • tharpa 2010-04-06 09:01
    PyroTyger:
    Barely related, forgive me...

    I remember marking test-papers for a particularly obtuse and unoriginal A-level Philosophy teacher. He had posed the classic question (and oh! how my ribs ached): "Is this a question?"
    There were several answers along the lines of "Yes", "No" or "Only if this is an answer". The only one that made me laugh was:
    "Are you trying to be clever?"

    The only one that got full marks was:
    "I don't know!!!"


    Then you're a #!#*. The only correct answer is, "Yes" and its equivalents. (Assuming it's agreed what "this" refers to.)
  • tharpa 2010-04-06 09:31
    Chris:
    You left out the four-fold state of existence according to Buddhist philosophy:

    enum Bool {
    True,
    False,
    BothTrueAndFalse,
    NeitherTrueNorFalse
    }

    I guess that FNF is equivalent to "neither nor", but it's sometimes nice to have both at the same time, too.


    So as not to misrepresent the Buddha's teachings, he only used this classification when referring to indulgence in speculations about irrelevant things. For example, there were people who would say that the world is eternal, and others who would say that the world is not eternal, and others who would say that the world is both eternal and not eternal, and still others who would say that the world is neither eternal nor not eternal, but that his teachings were not concerned with such questions, but only with the path leading to the cessation of suffering.

    In some later Buddhist circles, people would completely miss the point of such enumerations.