Some questions on Slate syntax

Steven Shaw steshaw at gmail.com
Mon Mar 28 00:56:35 PST 2005


> C just followed the convention that had been established by Algol,
> Pascal, and assembly languages. (0-based indexing is also simpler in
> languages that support pointer arithmetic.)

The index of Pascal arrays depends on subrange type.

  var myarray : array [0..40] of Character;

(or something like that - I don't have a pascal manual/compiler handy)

However, I prefer 0-based arrays by default being an old C programmer
(then C++ ... then Java). I didn't realise that Smalltalk arrays are
1-based until you mentioned it. I guess you often don't index into the
array for specific elements but more often obtain all the elements by
iteration (#do:).

There'd be nothing to prevent anyone from writing a Array1Based class
that transformed all the at: and at:put: calls appropriately. You
could even write a PascalArray class that takes the lower and upper
bounds of the array...




More information about the Slate mailing list