I didn't go into detail there, John, but it's worth noting that
originally Codd thought that there should be several different
NULL values for relational databases. Later in life, he came to
believe that NULL values (both the single NULL value in SQL
databases and the multiple NULL values in his original relational
papers) were bad.
No, as I remember it, his problem wasn't with NULL, but rather the
DB design.
ie. All instances where you have NotApplicable or NoThing null IN
A DB TABLE can be refactored to a better relational design that
didn't require them.
Um. In part, yes. The point is, though, that Codd believed toward
the end that multiple NULL values weren't nearly as useful as once
advocated.
However, having factored the DB into more tables so neither
variety of NULL occurred, there is still a need for NULL. There is
still a need on occasion to construct reports for user display
which are joins of various tables. And in those "views" there may
be some fields are going to be NULL. And again, it is still
necessary to disambiguate between NotApplicable and NoThing.
Is it? I don't think so, based on my experience. More often than
not, NULL -- whether "Not Applicable" or "No Thing" is blanked or
zeroed depending on the nature of the database.
Your proposal of multiple types of nil makes life harder. Instead
of:
if foo.nil?
# blah
end
I would have to do:
if foo.nothing? or foo.undefined? or foo.not_applicable?
# blah
end
How about starting with the following in the core
[snip implementation of bad proposal]
It still expands the number of tests that we would ultimately have
to deal with for very questionable gain. You haven't convinced me
that the need for knowing the difference between a Nothing nil and
an Undefined nil, etc. is worth knowing. To be more specific, I have
not yet needed such a differentiation in ten years of professional
software development.
Now if the rest of the system chose the right version of nil when
it assigned nil to something, the problem would go away and we can
extend the NoThing in a sane harm free fashion.
*shrug* I still don't think that it's valuable. Where's the Real
World Applicability?
The problem, as others have stated, is that adding #empty? to
NilClass implies a containment. I'd have as big a problem if we
added #empty? to Fixnum so that 0 returned true and everything
else returned false. (Indeed, would that be correct? Would
-3.empty? be true or false?)
Tut! Tut! I'm having this same problem with my son at school, they
teach him the rote mechanics, but forget to teach the principles.
(To be fair, I only started learning these things when I start
reading foundations of mathematics type books from the university
library...)
Come now, what is 3? 3 is 1+1+1. What do we mean by 1+1+1 we mean
three contains a 1 and a 1 and a 1! So if I extract the contents
of three I get 1 and 1 and 1 back.
And -3? Surprise surprise it contains three minus ones!
There is a strong overlap between core system design and axiomatic
mathematics.
Um. No wonder you're having problems, if you are trying to teach him
things that aren't real. I'll be the first to admit that I'm weak,
but I don't recall arithmetic or numerical theory being based on set
theory (that is, numbers as sets).
-austin
···
On 8/11/05, John Carter <john.carter@tait.co.nz> wrote:
On Thu, 11 Aug 2005, Austin Ziegler wrote:
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca