• (cs) in reply to OneFactor
    OneFactor:
    limelight:

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?

    how about making it consistent with order by and making it less than every non-null value?

    select 1 foo from dual union select -1 from dual union select null from dual order by foo

    will put the null at the very top. That sure looks like null is "less than the minimum value". Which brings us full circle to null remains after deleting everything greater than or equal to the minimum [*-)]

    Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.

    For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.

  • (cs) in reply to Brian
    Anonymous:
    foxyshadis:
    limelight:

    This is logical as null basically means the absence of a value or an unknown/unspecified/undefined value. Comparing null to itself is like saying, "does some undefined value equal some other undefined value", which is indeterminate.

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?


    Null is 22. I thought everyone knew that. I don't know what's wrong with language designers but I'm always having to use #define null 22 or public static final int null = 22. You'd think someone would get a clue! In the same way Empty is 22/3 and Nothing is -22/7.

    And I always thought null should be 42.

    Of course not, 42 is the value of True

  • (cs)

    Careful?  Seems a bit cavalier to me.   This assumes the table 'HashIndex' indeed exists, and has the field named 'ItemHash'.

  • Oracle Fan Boy (unregistered) in reply to limelight
    limelight:
    OneFactor:
    limelight:

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?

    how about making it consistent with order by and making it less than every non-null value?

    select 1 foo from dual union select -1 from dual union select null from dual order by foo

    will put the null at the very top. That sure looks like null is "less than the minimum value". Which brings us full circle to null remains after deleting everything greater than or equal to the minimum [*-)]

    Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.

    For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.

    Of course real databases like Oracle allow you to specify how to sort the NULLs in your order by clause

    ORDER BY [fields] NULLS FIRST/LAST

  • AKrotkov (unregistered) in reply to foxyshadis
    foxyshadis:
    limelight:

    This is logical as null basically means the absence of a value or an unknown/unspecified/undefined value. Comparing null to itself is like saying, "does some undefined value equal some other undefined value", which is indeterminate.

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?


    Null is 22. I thought everyone knew that. I don't know what's wrong with language designers but I'm always having to use #define null 22 or public static final int null = 22. You'd think someone would get a clue! In the same way Empty is 22/3 and Nothing is -22/7.


    Hahah, nothing is about equal to negative pi?


  • vhawk (unregistered) in reply to masklinn
    masklinn:
    Anonymous:
    foxyshadis:
    limelight:

    This is logical as null basically means the absence of a value or an unknown/unspecified/undefined value. Comparing null to itself is like saying, "does some undefined value equal some other undefined value", which is indeterminate.

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?


    Null is 22. I thought everyone knew that. I don't know what's wrong with language designers but I'm always having to use #define null 22 or public static final int null = 22. You'd think someone would get a clue! In the same way Empty is 22/3 and Nothing is -22/7.

    And I always thought null should be 42.

    Of course not, 42 is the value of True



    No no no !!!   We all know that 42 is the answer to Life the Universe and Everything.  By deduction null should then be !(42).
  • (cs) in reply to Oliver Townshend
    Anonymous:

    Encountered this at one site (sorry, syntax will be wrong)

     

    define cursor @table_del select id from table

    declare @id varchar(10)

    fetch @table_del into id

    while @@fetch_status=0 begin

       delete from table where id=@id

       fetch @table_del into id

    end

     

    I'm sure it also had stuff to make sure the cursor was unaffected etc. by the changes.  It took me several minutes of reading it before I realized what it was.

    Oliver Townshend



    This is obviously sub-optimal. The cursor should have been defined as

    define cursor @table_del select id from table where id in (select id from table) or id is null

    sheesh...!

  • (cs) in reply to Apoch
    Apoch:

    rogthefrog:

    At least you had fingers and toes. Back in my day, I lived at the bottom of a lake, and giant monsters would come out and nibble on me fingers and toes till all I had left were stumps. I had to write my data schemas with me nose in the mud, and as soon as a carp stirred I lost everything and had to start all over again.

    Plus the mud was hosted by 1and1.

    Pffft... mud is easy. Back in my day, we only had one cell. That's right, one cell. Try keeping state on that.

    Damn newbies.



    Pshaw!
    In my violent past, we expressed bytes by lining up our enemies and shooting the ones that were zeroes. Can you imagine the bloodbath when we tried to express 1 in a long double?
  • Madge O'Reene (unregistered)

    FIRST [:D]

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    [+o(]

  • (cs) in reply to ZeoS
    Anonymous:
    This remembers me another SQL code I saw once:
    drop MyTable;
    create MyTable .....
    :#


    Makes a lot of sense if you aren't sure that the table already has the required format.

  • GeneralPF (unregistered) in reply to rogthefrog
    rogthefrog:
    If you have access to the table schema and the right permissions, it might be faster to do a

    DROP TABLE IF EXISTS ItemHash;
    CREATE TABLE ItemHash (table def);

    if you're emptying the table completely.


    No way, then you'd lose the indexes.

    On that note, you can't TRUNCATE TABLE a table that references another table, at least in SQL Server.

    If the programmer was really concerned about the mandatory WHERE clause, why not do a WHERE 1 = 1?
  • (cs) in reply to GeneralPF

    Suppose he wanted to delete nothing:

    <font color="#000099">DELETE FROM</font> HashIndex
    <font color="#000099">WHERE</font> ItemHash > (<font color="#000099">SELECT MAX</font>(ItemHash) <font color="#000099">FROM</font> HashIndex)

  • (cs) in reply to dhromed

    dhromed:
    Suppose he wanted to delete nothing:

    <FONT face="Courier New" size=2>"suposse".</FONT>

  • (cs) in reply to captcha!
    Anonymous:

    god this forum software sucks...

    You guys must be regular posters on Slashdot.   http://en.wikipedia.org/wiki/Slashdot_subculture


    Slashdot is the biggest repository of tech retardation on the Web, so no, I do not count myself among the anti-M$ morons that blabber endlessly on slashdot.
  • (cs) in reply to limelight
    limelight:
    OneFactor:
    limelight:

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?

    how about making it consistent with order by and making it less than every non-null value?

    select 1 foo from dual union select -1 from dual union select null from dual order by foo

    will put the null at the very top. That sure looks like null is "less than the minimum value". Which brings us full circle to null remains after deleting everything greater than or equal to the minimum [*-)]

    Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.

    For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.

    So what's wrong with making null count as if it is less than the minimum value and not more than the maximum value? and at the very least it should equal itself. The whole null thing is so counterintuitive.

    In databases: null = null, null > null, null < null, null != null, null <> null all return false
    In Java, null == null returns true but float.NaN == float.NaN returns false, and I cannot remember what happens if float.NaN != float.NaN gives the same result as float.NaN < float.NaN || float.NaN > float.NaN.  The idea that < or > is different from != boggles the mind.

  • (cs) in reply to OneFactor
    OneFactor:
    limelight:
    OneFactor:
    limelight:

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?

    how about making it consistent with order by and making it less than every non-null value?

    select 1 foo from dual union select -1 from dual union select null from dual order by foo

    will put the null at the very top. That sure looks like null is "less than the minimum value". Which brings us full circle to null remains after deleting everything greater than or equal to the minimum [*-)]

    Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.

    For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.

    So what's wrong with making null count as if it is less than the minimum value and not more than the maximum value? and at the very least it should equal itself. The whole null thing is so counterintuitive.

    In databases: null = null, null > null, null < null, null != null, null <> null all return false
    In Java, null == null returns true but float.NaN == float.NaN returns false, and I cannot remember what happens if float.NaN != float.NaN gives the same result as float.NaN < float.NaN || float.NaN > float.NaN.  The idea that < or > is different from != boggles the mind.

    The confusion comes in taking null to be an object in and of itself. Null is not an object, but more like a state. A value can be null (in a null state), but cannot be null (an object). Consider that null basically means "an undefined value" or "the absence of a known value". If we replace the word "null" with its definition then the equations make a little more sense:

    null == null: translates to "an undefined value equals some other undefined value": result: indeterminate
    null > null: translates to "an undefined value is greater than some other undefined value": result: indeterminate
    ...etc.

    Take the case of null == null. What we are evaluating is whether the value on the left side of the equation equals the value on the right. What is the value on the left? We don't know (that's what null means, "an undefined value" or "the absence of a known value"). What is the value on the right? We don't know. Are they equal? We don't know.

    As far as <> being different than !=, they are indeed different. The <> implies order, but some objects have no order. For example, the rational, real numbers have order:

    1,2,3,4,5...

    but the complex numbers do not:

    1 + 2i is not necessarily greater than 1 + 1i since there are two axis of direction (the real number plane and the imaginary number plane). Likewise 2 + 1i is not necessarily greater than 1 + 1i. So when dealing with objects that have no order, greater than or less than have no meaning.

     

  • Nate (unregistered)

    Probably was a novice SQL programmer who didn't know that you don't need a WHERE clause with the DELETE statement. [pi]

  • Zygo Blaxell (unregistered) in reply to Maurits
    Maurits:
    emurphy:
    Anonymous:
    ah, this isn't too bad to be honest. he/she is an obviously a relative newb to SQL and thought that "delete from" had a mandatory "where" clause.


    This is actually true in MySQL (insert MySQL flames here) if you use the --I-am-a-dummy flag.


    OMG it's real...
  • Gary Wheeler (unregistered) in reply to Manni
    Manni:

    Back in my day, you had to write the one's and zero's out with a stick in a small box of sand sitting on your desk. Kids got it so easy these days.

    Sissy. They gave you a stick. We used our bare fingers.

  • (cs) in reply to limelight
    limelight:

    As far as <> being different than !=, they are indeed different. The <> implies order, but some objects have no order. For example, the rational, real numbers have order:

    1,2,3,4,5...

    but the complex numbers do not:

    1 + 2i is not necessarily greater than 1 + 1i since there are two axis of direction (the real number plane and the imaginary number plane). Likewise 2 + 1i is not necessarily greater than 1 + 1i. So when dealing with objects that have no order, greater than or less than have no meaning.

    But if greater and less DO have meaning, surely they should correspond to the definition of not equals. In SQL queries, where not (a = b) does not mean the same as where (a <> b) even though < and > have meaning. This constitutes absolute rubbish.

  • (cs) in reply to OneFactor
    OneFactor:
    limelight:

    As far as <> being different than !=, they are indeed different. The <> implies order, but some objects have no order. For example, the rational, real numbers have order:

    1,2,3,4,5...

    but the complex numbers do not:

    1 + 2i is not necessarily greater than 1 + 1i since there are two axis of direction (the real number plane and the imaginary number plane). Likewise 2 + 1i is not necessarily greater than 1 + 1i. So when dealing with objects that have no order, greater than or less than have no meaning.

    But if greater and less DO have meaning, surely they should correspond to the definition of not equals. In SQL queries, where not (a = b) does not mean the same as where (a <> b) even though < and > have meaning. This constitutes absolute rubbish.

    The point that I was making earlier is that, while <> usually can be used synonymously with "not equal", they are not fundamentally the same. You are correct that if objects have order than object a cannot be both less than or greater than b and yet also equal to b. Can you give a specific SQL example for values a and b where this takes place? Note that any example that includes null for a or b does not qualify as null has no order.

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

    god this forum software sucks...

    You guys must be regular posters on Slashdot.   http://en.wikipedia.org/wiki/Slashdot_subculture


    Slashdot is the biggest repository of tech retardation on the Web, so no, I do not count myself among the anti-M$ morons that blabber endlessly on slashdot.


    Given a suitable filter setting, Slashdot has a better signal to noise ratio than this forum (great jokes and puns notwithstanding). But if you think Microsoft is renowned for well-tested software and uses exemplary business practices, Slashdot probably isn't the place for you anyway.

  • Big Guy (unregistered) in reply to Steven Padfield

    Only if ANSI_NULLS is on

  • Darryl Bleau (unregistered) in reply to limelight
    limelight:
    OneFactor:
    limelight:
    OneFactor:
    limelight:

    As far as ordering goes, lets assume for a minute that null was less than or equal to a given value. Where exactly in the set of ordered values would null go?

    ...-3,-2,-1,null,0,1,2,3...?
    or
    ...-1,...,-0.1,...,-0.001,...,-0.000000001,...,null,0,...?

    how about making it consistent with order by and making it less than every non-null value?

    select 1 foo from dual union select -1 from dual union select null from dual order by foo

    will put the null at the very top. That sure looks like null is "less than the minimum value". Which brings us full circle to null remains after deleting everything greater than or equal to the minimum [*-)]

    Null also remains after deleting everthing that is less than or equal to the maximum. So in one case, null acts as though it is less than every value while in the other it acts as though it is greater than them. This brings us back to the fact that null is outside of the set of values and therefore cannot be less than, equal to or greater than any value.

    For obvious practical reasons, when you select data from a database that contains null values, the records have to go somewhere and, for lack of a better place, are sorted to be as though they are at the bottom of the range of values.

    So what's wrong with making null count as if it is less than the minimum value and not more than the maximum value? and at the very least it should equal itself. The whole null thing is so counterintuitive.

    In databases: null = null, null > null, null < null, null != null, null <> null all return false
    In Java, null == null returns true but float.NaN == float.NaN returns false, and I cannot remember what happens if float.NaN != float.NaN gives the same result as float.NaN < float.NaN || float.NaN > float.NaN.  The idea that < or > is different from != boggles the mind.

    The confusion comes in taking null to be an object in and of itself. Null is not an object, but more like a state. A value can be null (in a null state), but cannot be null (an object). Consider that null basically means "an undefined value" or "the absence of a known value". If we replace the word "null" with its definition then the equations make a little more sense:

    null == null: translates to "an undefined value equals some other undefined value": result: indeterminate
    null > null: translates to "an undefined value is greater than some other undefined value": result: indeterminate
    ...etc.

    Take the case of null == null. What we are evaluating is whether the value on the left side of the equation equals the value on the right. What is the value on the left? We don't know (that's what null means, "an undefined value" or "the absence of a known value"). What is the value on the right? We don't know. Are they equal? We don't know.

    As far as <> being different than !=, they are indeed different. The <> implies order, but some objects have no order. For example, the rational, real numbers have order:

    1,2,3,4,5...

    but the complex numbers do not:

    1 + 2i is not necessarily greater than 1 + 1i since there are two axis of direction (the real number plane and the imaginary number plane). Likewise 2 + 1i is not necessarily greater than 1 + 1i. So when dealing with objects that have no order, greater than or less than have no meaning.

     



    Interesting, but I would argue that NULL is more akin to "Is Not", perhaps better stated as "Absence of being", "Un-Being", or maybe you like "Opposite of existance". NULL is everything that never was and that will never be. I like to think of it as just plain "nothing", some students of philosophy may recognize this as a "No-Thing", or, a "Thing That Is Not".

    So in the case of:

    NULL == NULL

    We are simply asking if nothing is the same as nothing, which is logically true. In this case, NULL itself is actually quite well defined. Using NULL as a specifier of an undefined value is a misuse of NULL, languages should have a construct to test and specify whether a value has been defined or not, as not being defined is a distinct and separate state from being defined as NULL. Consider preprocessor directives:

    #define VALUE

    VALUE is defined as nothing, nada, not a thing, otherwise affectionately known as NULL. VALUE "Is Not", it is a "No Thing". However:

    #if defined(VALUE)
    or if you prefer:
    #ifdef VALUE

    Is true.

    For the other operations then, we can logically conclude that:

    (NULL > NULL) = FALSE, (NULL < NULL) = FALSE, and (NULL != NULL) = FALSE. NULL and NULL are the same thing, one cannot be greater than the other.

    Ordering NULL of course makes no sense, because ordering is an operation one applies on things, and NULL is already clearly defined as a "No-Thing". Nothing can be in order, but one cannot perform an ordering on nothing, as said action would itself be nothing and thusly nullified. (How can nothing be in order, the astute in the audience now question? Nothing is obviously in order with itself, but cannot be ordered against things which are, because ordering is an operation performed by definition solely on things which be. If you prefer, Being and Nothingness are distinct elements which cannot be ordered against each other, but Nothingness can be ordered against itself, but this is mostly a fruitless action as there are no other things with which to order it by).

    If you put a gun to my head and forced me to order NULL into the sequence:

    -3, -2, -1, 0, 1, 2, 3

    I would order thusly:

    -3, -2, -1, [0|NULL], 1, 2, 3

    As "0", a concept of "None", is inherently cohesive with "Not Being". I would then walk away from you, crazy person with the gun, and not feel too badly about myself.

    In many C programs, one can discern the author's confusion between "A Defined Object" and "Nothing" plainly whenever you see code like:

    char *getValue(void *fromSomething)
    {
        char *resultOf = someOtherFunction(fromSomething);
        if (!resultOf)
            return strPut(""); // ick
        else
            return resultOf;
    }

    Unless you are purposefully returning an empty string as a workaround to some flawed library you are using, this is wasteful and not required. One could simply:

    char *getValue(void *fromSomething)
    {
        return someOtherFunction(fromSomething);
    }

    Obviously this is a contrived example. Let's put it in more real-world terms, where we are parsing an RFC822 message and getting back the value of a specific header:

    char *headerValue(char *headerName)
    {
        return parseMessageToFindHeader(headerName);
    }

    (Of course, this isn't production code so don't read too much into it past the concept of returning NULL versus an empty string).

    Given:

    To: Bob
    From: Joe
    Subject: Hello

    headerValue("To")

    returns "Bob", as expected, and:

    headerValue("Foo")

    returns NULL. In terms of English, the "To" header value is "Bob", and there isn't a value of the "Foo" header, as it doesn't exist. In other words, the value of the non-existant "Foo" header isn't. Is Not. NULL.

    And just because I'm on the subject:

    strlen(NULL)

    Is of course, 0. This string length of NULL is not undefined, and should not return undefined (or worse, die!). If you're a skeptic, fear not, I'll guide you along.

    NULL as previously mentioned is very clearly defined as "No-Thing" or "Not-a-thing", so the real world translation of this (the string length of nothing) is quite easy to conceptualize. In whatever room you happen to currently be sitting, carefully look around and count the number of live adult dinosaurs contained in the room where you are. Unless you happen to have developed some sort of time traveling device or discovered how to grow dinosaurs on your own, the answer is likely: 0. How did you derive this answer? You carefully scanned every nook and corner of the room, and determined that there was a total lack of existing dinosaurs in the room. That is, all of the dinosaurs in the room weren't. They all were not. The dinosaurs in the room were completely in a state of non-being. When you count the array of dinosaurs in the room (Nothing), you discover that there are exactly 0 dinosaurs. Just as we were looking for "the string length of nothing", we were now looking for "the head count of no dinosaurs". Said more simply:

    count(lookForDinosaurs()) = 0;

    We've established that in our search for dinosaurs we didn't discover any, so there are no dinosaurs in our room, or, all the dinosaurs in our room don't exist, so the lookForDinosaurs action we engaged in gave us back exactly Nothing. ("I looked for dinosaurs in my room and came up with nothing"). So we can restate:

    count(Nothing) = 0;

    Nothing, the No-Thing, Not-A-Thing, a.k.a. NULL. Now we're at:

    count(NULL) = 0;

    strlen is a type of counting action. It's not a great leap to arrive at:

    strlen(NULL) = 0;

    Ok, I'm done. That, or, the rest of this post is NULL, however you'd like to think of it.
  • (cs) in reply to Darryl Bleau

    Darryl Bleau:

    Interesting, but I would argue that NULL is more akin to "Is Not", perhaps better stated as "Absence of being", "Un-Being", or maybe you like "Opposite of existance". NULL is everything that never was and that will never be. I like to think of it as just plain "nothing", some students of philosophy may recognize this as a "No-Thing", or, a "Thing That Is Not".

    What you have to keep in mind here is that we are not talking about a philosophical idea of what null means, but are instead referring to its specific definition as regards to database technology. Here is the first paragrah from the Microsoft SQL Server documentation regarding null values, which says exactly the opposite of what you just said:

    "A value of NULL indicates the value is unknown. A value of NULL is different from an empty or zero value. No two null values are equal. Comparisons between two null values, or between a NULL and any other value, return unknown because the value of each NULL is unknown."

    Wikipedia (for what it's worth) says,

    "Columns in Relational database management systems (RDBMS) can optionally store NULL values. The presence of a NULL value indicates that the actual value of the column is unknown or not applicable.

    In most RDMBSs, the result of testing NULL = NULL is FALSE. This is because one unknown value might not be equal to another unknown value".


    Darryl Bleau:

    So in the case of:

    NULL == NULL

    We are simply asking if nothing is the same as nothing, which is logically true. In this case, NULL itself is actually quite well defined.

    As per the explanation found in my previous posts and the documentation given above, evaluating "null == null" returns an undefined (null) result.

    Darryl Bleau:

    Using NULL as a specifier of an undefined value is a misuse of NULL

    If this is true, then most all major databases misuse null. Again, see the documentation posted above in response to your first paragrah.

    Darryl Bleau:

    languages should have a construct to test and specify whether a value has been defined or not, as not being defined is a distinct and separate state from being defined as NULL. Consider preprocessor directives
    #define VALUE

    VALUE is defined as nothing, nada, not a thing, otherwise affectionately known as NULL. VALUE "Is Not", it is a "No Thing". However:

    #if defined(VALUE)
    or if you prefer:
    #ifdef VALUE

    Is true.

    "VALUE" itself is a varaible, which is defined. The value of "VALUE" (confusing, I know) is null as it has not been defined.

    Darryl Bleau:

    For the other operations then, we can logically conclude that:

    (NULL > NULL) = FALSE, (NULL < NULL) = FALSE, and (NULL != NULL) = FALSE. NULL and NULL are the same thing, one cannot be greater than the other.

    The reason that null is not greater than or less than another null is not because they are the same, but rather because you cannot order an undefined value.

    Darryl Bleau:

    Ordering NULL of course makes no sense, because ordering is an operation one applies on things, and NULL is already clearly defined as a "No-Thing". Nothing can be in order, but one cannot perform an ordering on nothing, as said action would itself be nothing and thusly nullified. (How can nothing be in order, the astute in the audience now question? Nothing is obviously in order with itself, but cannot be ordered against things which are, because ordering is an operation performed by definition solely on things which be. If you prefer, Being and Nothingness are distinct elements which cannot be ordered against each other, but Nothingness can be ordered against itself, but this is mostly a fruitless action as there are no other things with which to order it by).

    Again, what we are talking about here are definite mathematical concepts, not philosophical ideas. We refer to the mathematical concept of order. Some sets simply have no order, such as the complex numbers pointed out in my previous post.

    Darryl Bleau:

    If you put a gun to my head and forced me to order NULL into the sequence:

    -3, -2, -1, 0, 1, 2, 3

    I would order thusly:

    -3, -2, -1, [0|NULL], 1, 2, 3

    As "0", a concept of "None", is inherently cohesive with "Not Being". I would then walk away from you, crazy person with the gun, and not feel too badly about myself.

    ... -3, -2, -1, [0|Undefined], 1, 2, 3 ...
    This makes no sense. Some things simply cannot be ordered.

    Darryl Bleau:

    In many C programs, one can discern the author's confusion between "A Defined Object" and "Nothing" plainly whenever you see code like:

    char *getValue(void *fromSomething)
    {
        char *resultOf = someOtherFunction(fromSomething);
        if (!resultOf)
            return strPut(""); // ick
        else
            return resultOf;
    }

    Unless you are purposefully returning an empty string as a workaround to some flawed library you are using, this is wasteful and not required. One could simply:

    char *getValue(void *fromSomething)
    {
        return someOtherFunction(fromSomething);
    }

    Obviously this is a contrived example. Let's put it in more real-world terms, where we are parsing an RFC822 message and getting back the value of a specific header:

    char *headerValue(char *headerName)
    {
        return parseMessageToFindHeader(headerName);
    }

    (Of course, this isn't production code so don't read too much into it past the concept of returning NULL versus an empty string).

    Given:

    To: Bob
    From: Joe
    Subject: Hello

    headerValue("To")

    returns "Bob", as expected, and:

    headerValue("Foo")

    returns NULL. In terms of English, the "To" header value is "Bob", and there isn't a value of the "Foo" header, as it doesn't exist. In other words, the value of the non-existant "Foo" header isn't. Is Not. NULL.

    Implementation of null outside of databases, as you show here, can sometimes get a little murky and is often used differently than null is used by databases. This is outside of the scope of the discussion.

    Darryl Bleau:

    And just because I'm on the subject:

    strlen(NULL)

    Is of course, 0. This string length of NULL is not undefined, and should not return undefined (or worse, die!). If you're a skeptic, fear not, I'll guide you along.

    NULL as previously mentioned is very clearly defined as "No-Thing" or "Not-a-thing", so the real world translation of this (the string length of nothing) is quite easy to conceptualize. In whatever room you happen to currently be sitting, carefully look around and count the number of live adult dinosaurs contained in the room where you are. Unless you happen to have developed some sort of time traveling device or discovered how to grow dinosaurs on your own, the answer is likely: 0. How did you derive this answer? You carefully scanned every nook and corner of the room, and determined that there was a total lack of existing dinosaurs in the room. That is, all of the dinosaurs in the room weren't. They all were not. The dinosaurs in the room were completely in a state of non-being. When you count the array of dinosaurs in the room (Nothing), you discover that there are exactly 0 dinosaurs. Just as we were looking for "the string length of nothing", we were now looking for "the head count of no dinosaurs". Said more simply:

    count(lookForDinosaurs()) = 0;

    We've established that in our search for dinosaurs we didn't discover any, so there are no dinosaurs in our room, or, all the dinosaurs in our room don't exist, so the lookForDinosaurs action we engaged in gave us back exactly Nothing. ("I looked for dinosaurs in my room and came up with nothing"). So we can restate:

    count(Nothing) = 0;

    Nothing, the No-Thing, Not-A-Thing, a.k.a. NULL. Now we're at:

    count(NULL) = 0;

    strlen is a type of counting action. It's not a great leap to arrive at:

    strlen(NULL) = 0;

    Actually, strlen returns the length of a null terminated string, excluding the null terminator. In this case, the function encounters null immediately and returns zero.

    Darryl Bleau:

    Ok, I'm done. That, or, the rest of this post is NULL, however you'd like to think of it.

    I agree, the rest of this post has definitely yet to be defined.

Leave a comment on “Greater Than or Equal to the Minimum”

Log In or post as a guest

Replying to comment #:

« Return to Article