Hi --

On Thu, 11 Aug 2005, John Carter wrote:

> On Thu, 11 Aug 2005, David A. Black wrote:
>
>>> The original poster had a NoThing type of nil. Your fear arises from the 
>>> possibility of applying the empty? method to an Unitialized or 
>>> NotApplicable type of nil.
>> 
>> I would say that asking whether nil is empty is like asking whether 12
>> is empty: it just doesn't mean anything.  Even having it say "false"
>> suggests that "true" is possible.  In general, I don't think
>> non-container objects should be declaring themselves "empty".
>
> class Fixnum
>  def each
>    # I'm throwing this exception, not because it is required,
>    # but because a headache is damping my imagination
>    # as to what -1.each means. I think it means the something
>    # like collect or sum, but my head hurts too much to say.
>    raise "Negative number" if self < 0
>
>    (1..self).each{|i| yield 1}
>  end
>
>  def empty?
>    self == 0
>  end
> end
>
> 12.each {|i| puts i}

Well, yes, Ruby lets you do that.  I would still argue that "it just
doesn't mean anything" :-)  I don't think that 0 is empty.
Containers contain 0 elements are empty.  0 isn't a container.

> What does NoThing contain?  Obvious it contains NoThing.
> noThing.shift returns noThing.  Is NoThing empty?  Yes.

This is a bit like "a ham sandwich is better than God" :-)  [1]  I'd
actually say there's a difference between: it contains [Nn]o[Tt]hing,
and: it's not a container.

> The current axioms of "nil" are valid and consistent.  But more
> useful, equally consistent axioms of "nil" can be proposed.

I look at it the other way around: not "What can nil evolve to from
what it is?" but "Is it desireable to have an object that has
no dimensional characteristics (no size, no fullness or emptiness,
etc.)?"  If it's good to have that, then it will either be nil or
whatever new term is created to replace nil if nil is changed.  So I'd
just as soon keep nil nil and come up with something else if there's a
demonstrated need for something else.

Anyway, in practical terms I would certainly agree with Austin that
one should not change nil in any code that one plans to share.


David

[1] I don't where it originated, but the syllogism goes: A ham
sandwich is better than nothing.  Nothing is better than God.  Ergo...

-- 
David A. Black
dblack / wobblini.net