• Denis Troller (unregistered)

    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 (cs)

    As it was then, so it is now and forever: "My eyes! The goggles do nothing!"

  • erKURITA (unregistered)

    Are you sure that dude isn't the same that "invented" the Nullity?

  • PyroTyger (cs)

    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 (cs)

    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 (unregistered)

    Doesn't use SQL some kind of ternary logic? true, false and unkown?

  • powerlord (cs) in reply to Flow
    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 (unregistered) in reply to powerlord

    ...or if you do it on purpose. NULL is distinctly different from true/false.

  • Hans (unregistered)

    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 (unregistered)

    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 (unregistered)

    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 (unregistered)

    so, in the enum, doesn't true = 0? that's messed up!

  • zellius (unregistered)

    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 (cs)

    True has value 0, and a Bool with 3 possible values. I have been here before.

  • Disco Stu (unregistered) in reply to DarkSprout
    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 (unregistered)

    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 (unregistered) in reply to Chris

    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 (cs) in reply to XPav

    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 (unregistered) in reply to Disco Stu

    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 (unregistered)

    $ cat is_alive cat: is_alive: filenotfound $

  • ewww (unregistered) in reply to zellius
    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 (unregistered) in reply to Chris
    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 (unregistered) in reply to Disco Stu
    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 (cs)

    I actually used this in a project once:

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

  • Schroedinger (unregistered) in reply to jspenguin
    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 (cs) in reply to jspenguin
    jspenguin:
    I actually used this in a project once:

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

    LOL. That's twisted.

  • Paula (unregistered)

    brillant.

  • Microsoft? (unregistered)

    http://msdn2.microsoft.com/en-us/library/bb384091.aspx

  • KattMan (cs) in reply to Microsoft?
    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 (cs) in reply to zellius
    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 (unregistered)
    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 (unregistered) in reply to KattMan
    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 (cs) in reply to dkf
    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 (unregistered) in reply to XPav

    You mean there is no determinate value until the system crashes ?

  • Dana (unregistered) in reply to Chris

    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 (unregistered) in reply to captain obvious
    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 (cs) in reply to KattMan
    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 (unregistered) in reply to Schroedinger
    Schroedinger:
    $ cat is_alive cat: is_alive: filenotfound $
    best comment ever
  • Peb0 (unregistered) in reply to clively
    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 (unregistered)

    Qubits anyone? enum QuantumBool { True, False, BothTrueAndFalse, NeitherTrueNorFalse, BetweenTrueAndFalse, GreaterThanTrue, LessThanFalse }

  • Jared Parsons (unregistered)

    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 (unregistered) in reply to XPav
    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 (unregistered)

    the real WTF is, that 0 will be assigned to true and 1 to false!

  • tharpa (cs) in reply to PyroTyger
    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 (cs) in reply to Chris
    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.

Leave a comment on “Classic WTF: What Is Truth?”

Log In or post as a guest

Replying to comment #:

« Return to Article