Counting from zero

Hans-Martin Mosner hmm at
Mon May 1 18:44:16 UTC 2006

Tom Phoenix wrote:

> But even then, if they had wished to measured a distance, what number
> would have marked the beginning of their measuring tape? If they had
> thought to measure time, what number would represent the beginning of
> their measurements?

You're getting to the heart of the matter here - intervals are not entities.
When you're measuring (macroscopically) continuous stuff like time and 
distance, it makes a lot of sense to let offsets start at 0, and to use 
half-open intervals. So the way from your origin (distance 0) to the 
first milestone (distance 1) is the first mile, although all points on 
it are labeled with a zero first digit.
Or time: your first year in life was the one up to the day you became 1 
year old. Then began your second year.

> How did their census takers report a home without
> children?

Now that's a completely different issue. (Indivisible) entities are best 
counted with integral numbers starting at 1. If you have one child, 
you'd write down the number 1, naturally. Without the digit 0, you'd 
probably mark the field with something else which states that there is 

Computer hardware (such as memory) can often be seen as almost 
continuous (or at least divisible) matter. Using half-open intervals to 
address it is very reasonable.

Smalltalk Arrays are mostly used like containers of discrete entities, 
which makes using 1-based indexes feel natural.
But of course, if your goal is to model core or disk memory, 0-based 
addressing is most likely better.


More information about the Squeak-dev mailing list