new Smalltalk programmer's thoughts
nicolas cellier
ncellier at ifrance.com
Mon May 1 13:07:44 UTC 2006
Hi Wolfgang,
Your point of view is correct, but sorry, it is a C point of view. That means
a point of view of how can i better insure the low level implementation.
And in fact, i trust you, it is more convenient to have 0-based if your are
dealing with pointers and offset.
But the aim of Smalltalk was not to ease such implementation. Smalltalk ignore
the notion of pointer, and assume all this low level goes into the VM.
Smalltalk goal is to ease the upper level programming. And at upper level,
sorry, if i want the object of rank 100 in a collection, i naturally write
(collec at: 100), and would find it very irritating to write (collec at: 99),
having to think of how the processor will translate this into an offset.
Looking at the history of numbers, you will discover that the zero is a
relatively new invention. Initially, it just meant empty, none or nihil (our
Smalltalk nil).
And looking closer at the english words, you know very well that fourth must
be associated to number four, fifth to number five, etc...
If you associate first to 0, then you associate fourth to 3, something that
does not sound natural to me.
That is why we index starting at 1 in Smalltalk, and why we are reluctant to
change that (though it is not at all in the syntax, just a convention choice
in the library).
Beside, it does not prevent us to use 0-based algorithm like with Stream
position, when what we need is an offset. So i do not really see that as an
obstacle.
It is just a programming habit, and i can tell you i also made a lot of
index-errors when switching between FORTRAN and C code, so the lack of errors
is not an objective criterium...
Nicolas
More information about the Squeak-dev
mailing list
|