replies inline.

On Apr 17, 2:15 am, Peter Becker <[email protected]> wrote:
>
> Traditionally zero is not a natural number.

Who cares about natural numbers? This is about the counting numbers,
and zero is undisputably a counting number. After all, if you're
counting and there's nothing there, you need some name for this
concept as well as a notation. The name is 'zero' and the notation is
'0' - at least, that seems the most sensible thing to pick. Given the
axiomatic need to represent the empty range somehow, there's no
dodging the need for the 0 concept.

> > RULE 2: In a list of, say, 10 elements, it would be odd if '11' is
> > anything other than an Out-Of-Bounds number.
>
> It isn't in either scheme.

But of course it is; in the indices start at 1 system, to make a copy
of a list you'd have to write list.subList(1, 11); and yet this won't
cause an IndexOutOfBoundsException. One could of course switch to a
system where the end is inclusive and not exclusive like java's. In
this case you'd end up with list.subList(1, 10), but now you get into
all the points dijkstra raised: The difference between the indices is
offset by 1 from the length of the sublist, and the thing I mentioned:
To represent an empty list you'd now need to write: list.subList(1,
0), which is weird. I'm going to make that axiomatic, by the way: I'm
taking it as natural and given that subList(1, 0) looks awkward. If
this is not axiomatic for you I'm not sure there's a point arguing, as
that would come down to taste. We could however spew facts about the
size of the population that thinks subList(1, 0) is acceptable, of
course.

>
> What is the smallest natural number? I studied math in Germany and there
> I learned that there is a set N (let's not add too much TeX -- the N
> should have the double bar on the left), which is the sequence starting
> at one, then repeatedly adding one. The numbers including zero are N_0
> (subscript zero). That is a bit old school, and there are many different
> conventions (see e.g.http://en.wikipedia.org/wiki/Natural_number). But
> saying "there is a smallest natural number" and implying it is zero
> hides the fact that conventions have been and continue to be different.

Dijkstra's point WASNT that the smallest natural number is zero. His
point instead was that the number BELOW whatever one picks as
'smallest natural number' will be required in most of the schemes that
aren't java. So, if you think 0 is ugly, then you could start at
offset 1, but you then also have to choose that end indices are
exclusive. Because if you don't, to describe the empty set you need to
write subList(1, 0) - and that 0 is one less than the lowest natural
number, and therefore, 'unnatural'. The same argument applies if one
DOES consider 0 as a natural number - if you do the end indicing as
inclusive you'd have to write subList(0, -1), which also includes an
unnatural number. This part of dijkstra's argumentation attempts to
prove that the only proper way to designate a range is for the start
index to be inclusive, and the end index to be exclusive.

You've also mentioned a few times that you don't consider the benefits
raised so far as relevant, but, let's flip it around then: What does
counting from 1 get you? At least counting from 0 gets you the ability
to describe the smallest and largest sublists in a way that is
consistent and doesn't have to dip into unnatural numbers on either
end.

>
> > Adhering to convention a) yields, when starting with subscript 1, the
> > subscript range 1 ≤ /i/ < /N/+1; starting with 0, however, gives the
> > nicer range 0 ≤ /i/ < /N/.
>
> What makes the second range nicer? I miss an argument supporting this
> statement.

The range 0 < i < N includes only numbers that fit within the set's
own counting numbers, whereas 1 < N + 1 contains a number that isn't a
counting number of the set (N + 1 itself).

>
> My personal opinion is that there are valid reasons why it is convenient
> for an implementation of array structures to use the convention Dykstra
> proposes as (a). You basically take the perspective of pointers (oddly
> enough not an argument Reinier or Dykstra made).

Of course not. Implementation is utterly irrelevant here. It would be
completely trivial for C to consider a[1] as simply dereferencing 'a'
as a pointer. In java in particular the same logic can be made. I'm
speaking now from the perspective of the compiler itself. If you'd
like to claim that it's easier for library writers (who are after all
'users' of the programming language) to work with 0 offsets then that
is of course a fine argument for why 0 offsetting is the only right
answer.

> I believe pretty much anyone else (including most
> mathematicians) tend to prefer 1-based indexing.

As dijkstra tried to highlight with his Mesa example, in practice 0-
based indicing is more consistent. It's a lesson you need to grok, but
once you do so it's all consistent. With 1-offsetting you lose some of
this, as for example a location offset has to be 0 based to make any
sense, and thus you always have to think: Is this 1-offset or 0-
offset? In other words, 0-offset is unavoidable, but 1-offset is. By
avoiding 1-offsets, all offsetting is 0 based and even if this feels
less natural for a beginning programmer its easier for everyone that's
been programming for longer than 7 days. As most programmers spend
more than 14 days programming, 0 offsetting wins. I freely admit I
pulled the number '7 days' out of you know where, but you get the
point, I presume.

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to