- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
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).
Admin
As it was then, so it is now and forever: "My eyes! The goggles do nothing!"
Admin
Are you sure that dude isn't the same that "invented" the Nullity?
Admin
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!!!"
Admin
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.
Admin
Doesn't use SQL some kind of ternary logic? true, false and unkown?
Admin
Yes, if you forget to declare a BOOLEAN column NOT NULL.
Admin
...or if you do it on purpose. NULL is distinctly different from true/false.
Admin
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... }
Admin
Triple State is NOT a world of fun, I'm a Access Database administrator, so, I know...
I'm afraid -- it makes perfect sense.
Admin
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
Admin
so, in the enum, doesn't true = 0? that's messed up!
Admin
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?
Admin
True has value 0, and a Bool with 3 possible values. I have been here before.
Admin
Access is a database?
Admin
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.
Admin
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.
Admin
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?!
Admin
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...
Admin
$ cat is_alive cat: is_alive: filenotfound $
Admin
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).
Admin
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).
Admin
Admin
I actually used this in a project once:
http://www.jspenguin.org/dvdfs/dvdfs.c
Admin
If you don't fix it, you'll have to answer to me, upon which you'll be NeitherFoundNorNotFound.
Admin
LOL. That's twisted.
Admin
brillant.
Admin
http://msdn2.microsoft.com/en-us/library/bb384091.aspx
Admin
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.
Admin
As I say, if the scope is big enough... if you want to go all OOPy on your project.
Admin
Admin
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.
Admin
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.
Admin
You mean there is no determinate value until the system crashes ?
Admin
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.
Admin
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 ;-)
Admin
Have you always had trouble reading or is it really just ADD kicking in.
Admin
Admin
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.
Admin
Qubits anyone? enum QuantumBool { True, False, BothTrueAndFalse, NeitherTrueNorFalse, BetweenTrueAndFalse, GreaterThanTrue, LessThanFalse }
Admin
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
Admin
also we need a value for current universe index.
Admin
the real WTF is, that 0 will be assigned to true and 1 to false!
Admin
Then you're a #!#*. The only correct answer is, "Yes" and its equivalents. (Assuming it's agreed what "this" refers to.)
Admin
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.