• JuJuBe (unregistered) in reply to Alex Papadimoulis

    "This is why tri-value languages will have an IsUnknown or IsNull test, which is the only thing that can be used to compare such values."

    By this logic, most programming languages are tri-value, but that doesn't excuse the fact that a boolean is T/F (on or off). To say that NULL is a valid boolean value is to miss the point entirely.

    What does this evaluate to?:

    boolean myBool;

    Does that make this a valid boolean from a systems perspective? That is why this triv-value stuff is bunk. There are always constraints you need to put on a system to make it work. In this simple case, you need to define myBool to some initial value to prevent nulling out. In the above case, a simple NOT NULL does the trick.

  • (cs) in reply to diaphanein
    Anonymous:

    Usually, I think people jump the gun when claiming code is generated, but for once I actually do think this was generated.  Rather moronically of course.

     

    I'm thinkin' it was generated, all right.  By morons!

  • (cs) in reply to JuJuBe

    Anonymous:

    Are you serious? A boolean is now a tri-value? Wow.

    Those of us who, you know, actually work with databases, and realize that a boolean column that is nullable does, in fact, have three distinct possible values.

    Check it out:  True, False, FileNotFoundNull.  Five values.  What?  Oh yeah, three.

     

  • (cs) in reply to FrostCat
    FrostCat:

    Anonymous:

    Are you serious? A boolean is now a tri-value? Wow.

    Those of us who, you know, actually work with databases, and realize that a boolean column that is nullable does, in fact, have three distinct possible values.

    Check it out:  True, False, FileNotFoundNull.  Five values.  What?  Oh yeah, three.

     

    Today's WTF:  FileNotFound was supposed to render in strikethru.  It does in the editor, but already know that is it's own WTF.  I bet it'd be better if it were in JavaScript.

  • (cs) in reply to FrostCat

    <font size="2">You heard it here first, folks: red is the new false.

    </font>

  • (cs) in reply to Dave L

    <font size="1" style="font-family: verdana;">

    Anonymous:
    If they replace true and false with #00ff00 and #ff0000 then I'll be impressed.

    Of course when they come across #ffff00 then they're fucked!



    <font size="2">Not if #ffff00 means FileNotFound.

    Or you could use this scheme to redefine the tri-state boolean: True, False, ASuffusionOfYellow.
    </font>
    </font>
  • Nano- (unregistered) in reply to Dave L

    That, of course, would be "false". ((#ffff00 = #00ff00 & #ff0000, and everyone knows true and false = false))

     #000000 on the other hand, would be "true" ;)

  • Jon (unregistered) in reply to FrostCat

    Anonymous:

    Are you serious? A boolean is now a tri-value? Wow.

    Precisely to prevent that kind of confusions, that's the reason I always use quaternary boolean logic: true, false, null and undefined.

  • (cs) in reply to Gene Wirchenko

    Gene Wirchenko:
    OneFactor:
    To understand the database you must unlearn the dualism you have learned in your computer science. And that, young grasshopper is why you need to place a W in front of the sacred letters of Boolean Algebra: TF.


    Transcending and not transcending: the new duality.

    Sincerely,
    Gene Wirchenko

    And so the circle closes. The naive solution of placing a not null constraint on the column does not solve the parameter or left-join issue. For if we treat 1 and 0 as truth because they are not null, and treat null as false, then we CAN restore duality to the database at all levels. And so, grasshopper, when and only when we transcend the difference between 1 and 0, do we then have the foundations for the two-valued dichotomies that the learned yearn for and the wise spurn.

    Your mission, should you choose to accept it, is to introduce transcendent negation, conjunction, and equivalence operators which operate or the 0,1,null set which correspond with the traditional boolean operators operating on the T,F set. If you fail on this road to enlightenment, your master will officially deny any knowledge of this endeavor - for the Tao which can be spoken is not the true Tao.

  • Matthew (unregistered) in reply to Satanicpuppy

    Satanicpuppy:
    Anonymous:
    I use the bit datatype for booleans in SQL Server.


    Meh. I use the smallest flavor of int, whatever it happens to be. Sounds a little wierd, but if you need to be able to represent null, you need more than 1 and 0. I prefer null = -1 myself, because -1 fits into a lot of languages built in error checking procedures.

     

    Umm, no you don't. There is already a value to represent Null. It is (drum roll) - Null!

  • phx (unregistered) in reply to Jon

    This is fantastic!

    True: #00ff00
    False: #ff0000
    Null: #0000ff
    Half-Truths: #008800
    False Positive: #ffff00
    Pessimistic false: #88ff00
    Intangible false: #ff0088
    Indecisive: #888800
    Who cares: #888888
    Purple: #C000C0

    This multistate logic is brilliant.

    And: Intangible False & Pessimistic False= #880000 (Barely false)

    Or: Half-Truth | Purple = #C088C0 (Rather gay looking indetermiate truth)

    Xor: False-Positive ^ Half Truth= #887700 (Kinda leaning towards false)

    Not: !Intangible False = #00ff77 (Slightly less tangible true)

    Its brilliant! I should patent it!

  • (cs) in reply to OneFactor
    OneFactor:
    ...for the Tao which can be spoken is not the true Tao.


    With SQL, this should be updated to "The Tao which can be spoken is not the NULL Tao."

    Sincerely,

    Gene Wirchenko

  • Kiss me, I'm Polish (unregistered) in reply to Gene Wirchenko

    I hate you all. I'm color blind.

  • (cs)
    Alex Papadimoulis:

    Relational databases don't have Boolean data types for good reason: the inherent nature of tri-value logic (i.e., true, false, and unknown/null) makes it a logical impossibility.


    No no, they've got it all wrong! It's Red, Green, and ErrTrafficFault.
  • (cs)

    The so-called "third state" of boolean, the null - has significance in that it simply points out that no decision has been made on true or false. No challenge has been encountered that would provide clarity.  It remains to be seen if the data proves one way or the other. It's waiting to be solved. By having an explicit true or false value, we also know that the data has been tested and resolves.
     
    Based on implementation, a nullable boolean ( or similar type ) could reveal something valuable if you're looking for an unproven true or false.

    Case in point: an incomplete survey. Lets say for whatever reason, the user failed to finish all the questions on a survey. When you run the metrics, you could safely ignore the null values rather than casting them to false, which might be the wrong assumption and bais the results.

  • (cs) in reply to phx
    Anonymous:

    This is fantastic!

    True: #00ff00
    False: #ff0000
    Null: #0000ff
    Half-Truths: #008800
    False Positive: #ffff00
    Pessimistic false: #88ff00
    Intangible false: #ff0088
    Indecisive: #888800
    Who cares: #888888
    Purple: #C000C0

    This multistate logic is brilliant.

    And: Intangible False & Pessimistic False= #880000 (Barely false)

    Or: Half-Truth | Purple = #C088C0 (Rather gay looking indetermiate truth)

    Xor: False-Positive ^ Half Truth= #887700 (Kinda leaning towards false)

    Not: !Intangible False = #00ff77 (Slightly less tangible true)

    Its brilliant! I should patent it!

    And for financial applications where the invoces are in dispute, the isPaid column can contain the color.... #BADFEE

  • (cs) in reply to OneFactor
    OneFactor:

    Young grasshopper, observe the stored procedure. Meditate on the beauty of its parameter declaration. See how the tiny bit datatype wishes to be free of the dualism imposed by two-valued western logic. For if the student knows NOTHING can be other than one or zero, the enlightened will learn know that nothing CAN be other than one or zero. Even as the brutish developer tries to coerce the parameter into but two values by providing a default of zero, the parameter yields like the slender reed to the howling storm and allows itself to be invoked with an explicit null...



    Bravo!  You made my day.

  • (cs) in reply to OneFactor
    OneFactor:

    Gene Wirchenko:
    OneFactor:
    To understand the database you must unlearn the dualism you have learned in your computer science. And that, young grasshopper is why you need to place a W in front of the sacred letters of Boolean Algebra: TF.


    Transcending and not transcending: the new duality.

    Sincerely,
    Gene Wirchenko

    And so the circle closes. The naive solution of placing a not null constraint on the column does not solve the parameter or left-join issue. For if we treat 1 and 0 as truth because they are not null, and treat null as false, then we CAN restore duality to the database at all levels. And so, grasshopper, when and only when we transcend the difference between 1 and 0, do we then have the foundations for the two-valued dichotomies that the learned yearn for and the wise spurn.

    Your mission, should you choose to accept it, is to introduce transcendent negation, conjunction, and equivalence operators which operate or the 0,1,null set which correspond with the traditional boolean operators operating on the T,F set. If you fail on this road to enlightenment, your master will officially deny any knowledge of this endeavor - for the Tao which can be spoken is not the true Tao.

    How about always reading from a computed column with the expression ISNULL(<colname>, 0), where colname is a bit column.  You will always read 1 or 0, even when the value is NULL and even for JOINS.  There is still a memory load in that you have to actually remember to join to the computed column, but it is possible.

    You could also go one step farther and create a View on the table using the expression above and INSTEAD OF triggers to make the view fully updatable.  Use permissions to funnel acces to the view instead of the table.  It's a lot of work and most likely not worth it, but it is possible.

  • Jesse (unregistered) in reply to OneFactor

    I think you are all #C00C00.

  • (cs) in reply to Gene Wirchenko
    Gene Wirchenko:
    LaurieF:
    But why isn't it in third-normal form? It's just wrong. [8o|]

    Codd is spinning in his grave.

    I doubt it.  If he were, given the atrocities committed with DBMSs, someone would have attached a generator to him, and we would have heard of this near-infinite source of electrical power.

    Sincerely,

    Gene Wirchenko


    ROFL!!! Shame on you! You made me wake my kid!

  • (cs) in reply to Jesse
    Anonymous:
    I think you are all #C00C00.


    "Touche"
  • (cs)

    I'm seeing a lot of common workarounds for the absence of Booleans; but, putting aside the tri-state issue, all of these hacks are a pretty poor substitute:

    myBool = not (myBool)

    is meaningless with all the hacks we use day in and day out.  The only exception I can think of was the old VB Boolean, where True = -1.  It was another hack; but, the compiler itself made this syntax functional.

     

  • The color commentator (unregistered) in reply to OneFactor

    Programming Test;

    Take one Green Crayola.

    Take one Brown Crayola.

    Mix the two together for the "Tri-State".

    What do you get?

    Brown.

    No Shit. . .  I mean, . . . .    well, brown, you know, like sh*t.  

    You either get it, or, you don't.   Or, maybe, you're just confused.

    unreal won't work. (captcha).  Maybe FREEDOM will. . .








  • Dirk (unregistered) in reply to cconroy

    <font style="font-family: verdana;" size="1"><font size="2">"Or you could use this scheme to redefine the tri-state boolean: True, False, ASuffusionOfYellow."

    Oh come on, am I the only one who gets this? :(
    </font>
    </font>

  • The color commentator (unregistered) in reply to phx
    Anonymous:

    This is fantastic!

    True: #00ff00
    False: #ff0000
    Null: #0000ff
    Half-Truths: #008800
    False Positive: #ffff00
    Pessimistic false: #88ff00
    Intangible false: #ff0088
    Indecisive: #888800
    Who cares: #888888
    Purple: #C000C0

    This multistate logic is brilliant.

    From peanuts. . .   You forgot "charmingly true"

    And: Intangible False & Pessimistic False= #880000 (Barely false)

    Or: Half-Truth | Purple = #C088C0 (Rather gay looking indetermiate truth)

    Xor: False-Positive ^ Half Truth= #887700 (Kinda leaning towards false)

    Not: !Intangible False = #00ff77 (Slightly less tangible true)

    Its brilliant! I should patent it!

  • mrwoo (unregistered) in reply to Dirk

    Anonymous:
    <FONT style="FONT-FAMILY: verdana" size=1><FONT size=2>"Or you could use this scheme to redefine the tri-state boolean: True, False, ASuffusionOfYellow."

    Oh come on, am I the only one who gets this? :(
    </FONT>
    </FONT>

    Pterry Pratchett again?

  • (cs)

    Can we not have SQL WTFs anymore? 

    1) They're generally incomprehensible (as is SQL itself)

    2) They're not interesting (because, let's face it, SQL is really just COBOL, and COBOL is friggin' dullsville, not to mention soooo last-century)

    3) Okay, so maybe SQL is really more like RPG and COBOL had a baby, but the point remains

    4) It's not really a WTF when someone does SQL badly, because it's not possible to do SQL well (along the lines of, "there's no such thing as playing the oboe well")

    5) I've already done my hitch in the RDBMS Corps, I don't want to go back, and don't need reminding that I was there in the first place

    Just a thought.  And not much of one, at that.

  • (cs)

    Not wanting to be a stick in the mud or anything, but, IMO, if a value can be anything other than TRUE or FALSE (including NULL) then it's not a true boolean.

    I realize it's rarely enforced, but the definition of boolean is: Of or relating to a data type or variable in a programming language that can have one of two values, true or false

    The REAL WTF here is that ANY system allows you to have a boolean value that is neither TRUE nor FALSE (ie: null or yellow, etc.)

    Case closed! ;)

  • (cs)

    Glenn? Is that you?
    --
    telnet towel.blinkenlights.nl 666


  • awefiujifwe (unregistered) in reply to itsnotbob
    The really, really bad part is that he's usig a SqlDataReader, which means that the database connection is open for the whole time while all that ridiculous logic runs.
  • Whelly (unregistered)

    Love the site, been reading it for months and months. Gives me hope every morning that everything isn't quite as bad as it seems.

    However, this WTF just had to be replied to. This is probably the worst .NET code I've seen in a long long time (and believe me I've seen some right corkers).

    SQL Server HAS a boolean equivalent (bit field with NOT NULL as everyone has stated), ADO.NET correctly maps this to a boolean type in both Readers and DataColumn's so WTF were they thinking of?

    My suggestion, apart from the ludicrous use of colours to depict yes/no is this could probably have been an ASP application that was ported (or was perhaps someone's first attempt at an ASP.NET application after coming straight out of the 'ASP' camp) without fully comprehending what they had available to them.

    A common first mistake when starting ASP.NET apps is approaching it like an ASP application. Was at a client's last year and they had done the same (purely out of inexperience of the CLR and underlying framework) and the code was an utter mess. Totally unmaintainable and damn right scaringly bad.

    Kept me busy for a good few months believe me getting things straight.



  • (cs) in reply to mrwoo
    Anonymous:

    Anonymous:
    <font style="font-family: verdana;" size="1"><font size="2">"Or you could use this scheme to redefine the tri-state boolean: True, False, ASuffusionOfYellow."

    Oh come on, am I the only one who gets this? :(
    </font>
    </font>

    Pterry Pratchett again?


    No, the untimely passed away Douglas Adams in his book 'The Long Dark Tea-time of the Soul".

    All Douglas Adams books are recommended reading material for programmers, or even for people pretending to be programmers.

    Christ

  • Hansiola (unregistered) in reply to JuJuBe

    Anonymous:
    "Relational databases don't have Boolean data types for good reason: the inherent nature of tri-value logic (i.e., true, false, and unknown/null) makes it a logical impossibility."

    Seriously, what?

    Are you serious? A boolean is now a tri-value? Wow.

    http://www.postgresql.org/docs/7.4/interactive/datatype-boolean.html
    http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html

    Anyway, yes, using Green/Red is kinda dumb, but no dumber than saying boolean is a 'tri-value'.

     

    Where does it say "boolean is a 'tri-value'?

     

  • zip (unregistered) in reply to mrprogguy
    mrprogguy:

    Can we not have SQL WTFs anymore? 

    1) They're generally incomprehensible (as is SQL itself)



    *snicker*
    [insert elitist programmer comment here]
  • ServerDude (unregistered) in reply to phx

    Man .. I know, I should've taken the blue pill ;)

    Imagine a designer meeting with all new people trying to agree on the colors for the different values. No one wants to back down .. hey, that's Resevoir Dogs isn't it.



  • (cs) in reply to witch
    witch:

    No, the untimely passed away Douglas Adams in his book 'The Long Dark Tea-time of the Soul".

    All Douglas Adams books are recommended reading material for programmers, or even for people pretending to be programmers.

    Christ


    imho Adams is one of the most overrated writers (among nerds, that is) out there. yes, i've read more than one of his books. no, i did not think they were brilliant; i thought thay were boring and plotless.

    have you ever read books by other authors?
  • Keith (unregistered)

    OK, this really looks similar to something I did 6ish years ago.  Except the Java has been replaced with .net .  And it wasn't an application form but a status monitoring.  But I can explain how something near identical happened...

    There was a database table which had to be displayed on a web page.  The guy doing the sql found out that it the column showing IsComplete was to be represented by images green.gif and red.gif so he thought he was doing me a favour by returning those strings.  He worked too slowly for me even to consider asking him to change it to a regualr boolean so as soon as he had some Stored Procs I could use I just made do.  Then later the picures were changed to checkboxes and the code ended up like the above.

     

  • (cs) in reply to Keith
    OneFactor:
    Young grasshopper, observe the stored procedure. Meditate on the beauty of its parameter declaration. See how the tiny bit datatype wishes to be free of the dualism imposed by two-valued western logic. For if the student knows NOTHING can be other than one or zero, the enlightened will learn know that nothing CAN be other than one or zero. Even as the brutish developer tries to coerce the parameter into but two values by providing a default of zero, the parameter yields like the slender reed to the howling storm and allows itself to be invoked with an explicit null.

    Consider also the left-outer join as it frolicks in your view. Unlike the inner join which only gives after it has received, the left-outer join has transcended selfish greed and the demands for O(n) performance. It can cheerfully give of itself as an orphan who has nothing even without the material riches provided by parents. And in doing so, it too will transcend the duality which the not-null constraint imposes.

    To understand the database you must unlearn the dualism you have learned in your computer science. And that, young grasshopper is why you need to place a W in front of the sacred letters of Boolean Algebra: TF.

    *Bows* Well said, Sir! Excellent "Programmer's Way of the Tao" form! Especially the "W before TF" was inspired, inspired I say!


    And so the circle closes. The naive solution of placing a not null constraint on the column does not solve the parameter or left-join issue. For if we treat 1 and 0 as truth because they are not null, and treat null as false, then we CAN restore duality to the database at all levels. And so, grasshopper, when and only when we transcend the difference between 1 and 0, do we then have the foundations for the two-valued dichotomies that the learned yearn for and the wise spurn.

    Your mission, should you choose to accept it, is to introduce transcendent negation, conjunction, and equivalence operators which operate or the 0,1,null set which correspond with the traditional boolean operators operating on the T,F set. If you fail on this road to enlightenment, your master will officially deny any knowledge of this endeavor - for the Tao which can be spoken is not the true Tao.


    The follow-up left a bit to desire, though. It is less coherent, the form is vacillating, and of less virtuouso a style.

    EnterUserNameHere:

    Not wanting to be a stick in the mud or anything, but, IMO, if a value can be anything other than TRUE or FALSE (including NULL) then it's not a true boolean.

    I realize it's rarely enforced, but the definition of boolean is: Of or relating to a data type or variable in a programming language that can have one of two values, true or false

    The REAL WTF here is that ANY system allows you to have a boolean value that is neither TRUE nor FALSE (ie: null or yellow, etc.)

    Case closed! ;)

    If your world is impoverished enough that you truly cannot think outside a strict boolean logic, or that you consider anything not a sentence formally reducable to a two-state mutually exclusive mode fundamentally flawed, or that computers should not be able to handle anything beyond the nature of it's smallest informational component, then you should change career and apply for a position as resident mollusk on a seal somewhere.

    The matrix of our minds are not binary, yet we can think in boolean terms. Ccomputers are binary on the lowest level, but why should that foundation make illegal the handling of anything different?

    Unless you simply mean that "if it is called 'boolean' then it should be two-state", that I can buy into.
  • Iago (unregistered) in reply to lukas
    lukas:
    imho Adams is one of the most overrated writers (among nerds, that is) out there. yes, i've read more than one of his books. no, i did not think they were brilliant; i thought thay were boring and plotless.

    have you ever read books by other authors?

    Sorry, but as a programmer who also happened to major in English, I can assure you that Adams' writing is indeed brilliant by any standards.  If you don't like his work, then presumably either you have a different sense of humour, or you yourself are the one who has not read widely enough to be able to appreciate his writing.  I'll give you the benefit of the doubt and assume the former.

    Oh, and Dirk Gently >> HHGG.  Alas for the lost Salmon of Doubt!
  • (cs) in reply to Iago
    Anonymous:

    Sorry, but as a programmer who also happened to major in English, I can assure you that Adams' writing is indeed brilliant by any standards.  If you don't like his work, then presumably either you have a different sense of humour, or you yourself are the one who has not read widely enough to be able to appreciate his writing.  I'll give you the benefit of the doubt and assume the former.

    Oh, and Dirk Gently >> HHGG.  Alas for the lost Salmon of Doubt!


    I think this would indeed come down to a matter of taste.
  • Akimoto (unregistered) in reply to Nano-

    "That, of course, would be "false". ((#ffff00 = #00ff00 & #ff0000, and everyone knows true and false = false))

     #000000 on the other hand, would be "true" ;)"

     

    Is this a WTF?

    #ffff00 = #00ff00 | #ff0000

  • (cs) in reply to Akimoto
    Anonymous:

    Is this a WTF?

    #ffff00 = #00ff00 | #ff0000

    Not if "|" is a "bit-wise or".

     

  • Asif Youcare (unregistered) in reply to Suck My Lisp

        This statement is a WTF itself.

    Indeed.  If one accepted the argument against storing booleans, one could make a similar argument against storing integers - coz people expect an integer value rather than a null,


  • (cs) in reply to lukas
    lukas:
    witch:

    No, the untimely passed away Douglas Adams in his book 'The Long Dark Tea-time of the Soul".

    All Douglas Adams books are recommended reading material for programmers, or even for people pretending to be programmers.

    Christ


    imho Adams is one of the most overrated writers (among nerds, that is) out there. yes, i've read more than one of his books. no, i did not think they were brilliant; i thought thay were boring and plotless.

    have you ever read books by other authors?


    As a matter of fact, I did... I've read books by Dean Koontz, Stephen King, Dan Brown, and scores of other authors. Not all of it could be considered 'high literature', but still... I've read more than 'just' Adams. And, as was also noted above, this is probably a 'taste' thing.

    I've also read them in Dutch, and I must assure you, the English originals are on the whole a lot better. Lots of jokes can be made to work, and some others were 'missed'...
  • (cs) in reply to witch

    I solve all isues with nullable boolean logic inside databases by:

    (field = 'Y' or field is null)

    And then use that small unit to replace the ineffectual:

    field <> 'N'

    I do not fully understand why null is not UNequal to a value such as 'N' or 'Y' or 'Cucumber', since it is obviously not equal to them.

    If the field can hold:

    N
    Y
    null

    Then why does [WHERE field <> 'N'] only select those where [field = 'Y'] and ignores the nulls as though they were equal to 'N'?

  • (cs) in reply to Strydyr
    Strydyr:
    Anonymous:

    Is this a WTF?

    #ffff00 = #00ff00 | #ff0000

    Not if "|" is a "bit-wise or".

     

     

    class kk {
     public static void main(String[] args) {
      System.out.println(0xffff00 == (0x00ff00 & 0xff0000));   // prints false
      System.out.println(0xffff00 == (0x00ff00 | 0xff0000));     // prints true
     }
    }

  • asdyt (unregistered) in reply to witch

    Shouldn't the third, indeterminate state really be "cat".

     

    It was popularised by Erwin Schrödinger in his book "QuantumDb".

  • (cs) in reply to Mikademus

    <Unless you simply mean that "if it is called 'boolean' then it should be two-state", that I can buy into.>

    That's exactly what I mean. If you need more than two states than pick another data type.

    Thanks

  • (cs)

    I looked at this code and understood why there is no normalization, if you produced this crap what are the odds that you ever heard of normalization.  I'm certain that if their db guy saw it and normalized it the original programmer would be at a loss as how to combine the results to achieve the front end code. No doubt we would see code like:

    <the language below is of no particular flavour>

    sqlquery1 = "select isComplete from PageStatustable"

    sqlquery2 = "select isComplete from PageStatustable"

    ....

    sqlquery25 = "select isComplete from PageStatustable"

    if result1 = "y" then

       sqlquery1_1 = "select content_page, title_page from pageContents"

    end if

    ...

    if result25 = "y" then

       sqlquery25_1 = " select content_page, title_page from pageContents"

    end if

     

    and so on and so on....

     

    How crap like this ever gets into production is beyond me. 

    Oh, if anyone wants to use this idea, please don't say it came from me.

     

  • (cs) in reply to JuJuBe

    JuJuBe:

    By this logic, most programming languages are tri-value, but that doesn't excuse the fact that a boolean is T/F (on or off). To say that NULL is a valid boolean value is to miss the point entirely.

    What does this evaluate to?:

    boolean myBool;

    Does that make this a valid boolean from a systems perspective? That is why this triv-value stuff is bunk. There are always constraints you need to put on a system to make it work. In this simple case, you need to define myBool to some initial value to prevent nulling out. In the above case, a simple NOT NULL does the trick.

    Depending on the language, this would evaluate to the default value (.NET, Java, etc), or a random value, based on whatever bits happened to be flipped in the memory space allocated for the variable (C, etc). The same holds true with ...

    int myInt;
    cout >> myInt;

    ... prints an possibly random, but still a valid integer value.

    Think of Nullable datatypes as ones where the IsNull bit is stored in the symbol table and not represented as some combination of bits in the variables memory space. Very languages have Null represented this way and have to resort to ugly "hacks" to implement the logic: creating a IntClass with an internal integer and a getter/setter for IsNull and Value, boxing all value-types and having a separate object to represent null, and so on ...

Leave a comment on “The Green, the Whole Green, and Nothing But the Green”

Log In or post as a guest

Replying to comment #:

« Return to Article