Why don't we have two nulls?

后端 未结 27 1084
孤独总比滥情好
孤独总比滥情好 2021-02-02 08:38

I\'ve often wondered why languages with a null representing \"no value\" don\'t differentiate between the passive \"I don\'t know what the value is\"

27条回答
  •  清酒与你
    2021-02-02 08:46

    Two nulls would be the wrongest answer around. If one null is not enough, you need infinity nulls.

    Null Could mean:

    • 'Uninitialized'
    • 'User didn't specify'
    • 'Not Applicable here, The color of a car before it has been painted'
    • 'Unity: This domain has zero bits of information.'
    • 'Empty: this correctly holds no data in this case, for example the last time the tires were rotated on a new car'
    • 'Multiple, Cascading nulls: for instance, the extension of a quantity price when no quantity may be specified times a quantity which wasn't specified by the user anyway'

    And your particular domain may need many other kinds of 'out of band' values. Really, these values are in the domain, and need to have a well defined meaning in each case. (ergo, infinity really is zero)

提交回复
热议问题