Jump to content

Talk:Null (computer programming)

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Unknown value

[edit]

I think "unknown value" aids in understanding the three-valued logic semantics in a way that "undefined value" doesn't... "A = Null" is "unknown", rather than true or false, because Null is an unknown value which may or may not be equal to A. Kobes 19:43, 25 February 2006 (UTC)[reply]

I strongly disagree. A variable whose value has been set to "NULL" isn't intended to be "unknown" - to the contrary - it's very well known - you just set it to NULL! I don't particularly like "undefined" either...but it's better by far than "unknown". SteveBaker (talk) 00:41, 24 March 2008 (UTC)[reply]
A better synonym would be "not set" or "unset", i.e., "does not have a known value". — Loadmaster (talk) 02:30, 24 March 2008 (UTC)[reply]
The value of null in trinary logic is well-defined but certainly not always well used. In SQL, NULL could mean either "unknown" ("Missing but Applicable") or "not set" ("Missing but Inapplicable"), depending on its exact context. The unfortunate part about this is that such a conceptualization of NULL does not really fit into 3-logic, but 4-logic. Because of this, the SQL use of NULL is rather... deficient; see Null_(SQL)#Criticisms.
In just a straight trinary logic table, using "unknown" as a synonym works conceptually, i.e., it behaves in the way you'd expect "unknown" to behave; however, in applications that use null as a trinary value like SQL, using either "unknown" or "not set" as a synonym can seed conceptual pitfalls. 68.82.171.129 (talk) 00:38, 26 January 2009 (UTC)[reply]
In SQL, there is a further problem with presenting NULL fields (e.g., date/time fields) in sorted lists. In some cases NULL should sort before non-NULL values, while in other cases it should sort after them. | Loadmaster (talk) 03:35, 27 January 2009 (UTC)[reply]

Null strings

[edit]

What are these sentences supposed to mean? Could someone give an example? The null string is not the same as the content of a string variable set to a null value. Null strings do not create 3-valued logic, in contrast to null values in strings. If you are referring to, for example, Java, when you say String s = null, that sets the reference s to null. There is no String object. -- Schapel (talk) 22:14, 13 March 2010 (UTC)[reply]

The sentences have been changed to something that seems more reasonable. However, the sentence Null strings do not create 3-valued logic seems wrong. a.equals(b) can be true, false, or result in a NullPointerException in Java, depending on the value of a in Java. That's not exactly the same as 3-valued logic, but there are 3 different results. -- Schapel (talk) 22:54, 13 March 2010 (UTC)[reply]
I am thinking more about strings in a database. A string field can contain a null string or have the null value. A null string is perfectly defined and does not give rise to 3-valued logic, being equal to only itself and unequal to any other string. A null value in a string field S makes the value undefined: the comparisons S = any string and S <> any string are both false. −Woodstone (talk) 04:20, 14 March 2010 (UTC)[reply]