new Smalltalk programmer's thoughts
yoshiki at squeakland.org
Mon May 1 18:41:41 UTC 2006
> Unix and C let zero be the first natural number. As you might know, the Unix V6
> kernel does not contain a single bug. Ironically, the only V6 program
> that I consider buggy is the debugger. Maybe this is because Ken Thompson and
> Dennis Ritchie didn't need the debugger. And maybe this is because they were
> trying to prove their programs to be correct while writing. And maybe this
> is the reason they decided to let zero be the first natural number.
The people's favorite language Perl has a special variable "$[" that
let you specify the index of the first element in an array.
As everyone wrote: it is about either to think about the n-th index
, or the offset or distance and I'd say that you can't simply say
which is more natural.
Also, in Smalltalk, Streams are 0-based as nicolas and others
a _ ReadStream on: 'ABC'.
a next. " => $A"
a position. "=> 1"
a position: 0.
a next. "=> $A"
a position: 3.
a next. "=> nil"
The AltoFileStream should've follow this convension, instead of
allowing [1..size] indices.
(The coordinates in a Form are 0-based, by the way...)
Just my $0.02,
More information about the Squeak-dev