Some questions on Slate syntax

David Hopwood david.nospam.hopwood at blueyonder.co.uk
Sat Mar 26 16:15:38 PST 2005


Bill Sun wrote:
> 1. Why 0-based arrays?
> 
> 0-based arrays don't seem to be as intuitive and easy to use as
> 1-based.  If you want to create an array with x elements, the last
> element's index is x-1, rather than just plain old x.

OTOH with the 0-based convention, the loop index is x when x array
elements have already been completely processed.

> Not only is
> there an extra calculation involved, but if you're careless or just
> happen to typed a typo, you'll get one of those bugs that you'll want
> to slap yourself in the face with.

This argument does not stand up in practice: in my experience, 0-based
indexing involves fewer add/subtract 1 operations overall, provided that
the "half open interval" convention is followed (intervals include their
first element and exclude their last, i.e. i <= x && x < j).

See <http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF>.

> Are there any practical advantages for using 0-based arrays?  I know
> many other languages also use 0-based arrays, but are there any other
> reasons besides that?

Well, that's a very good reason in itself. If other arguments were
roughly balanced, consistency would favour staying with the convention
used by other languages.

> 2. Why no arithmetic precedence in binary messages?
> 
> Again, it seems more intuitive to include arithmetic precedence as it's
> common knowledge.

I agree with this. OTOH Slate's syntax is derived from Smalltalk, which
did not have arithmetic precedence.

-- 
David Hopwood <david.nospam.hopwood at blueyonder.co.uk>




More information about the Slate mailing list