Some questions on Slate syntax

Bill Sun billksun at
Sun Mar 27 02:15:27 PST 2005

I think I understand what Lee is getting at.  0-based makes more sense
when you're looking at low level computing.  Which is more tailored to
how computers work.

But Shaping and myself are going from a human interfacing
point-of-view.    For the most of us 0 is neither a positve number nor
a negative number, it's that "mysterious" thing that sits in between. 
0 is nothing.  I have 0 rocks, means I have no rocks.

Furthermore, when counting, of course it would start at the first
natural number.  With arrays, we often find ourselves iterating over
them.  So it seems natural to refer to the n-th element in the array
as...well, the n-th element.

I guess this is why Smalltalk took the 1-based array approach.  As it
is  designed to be a high-level language that is more natural for
humans to interact with.

I believe when C adopted 0-based arrays, it was because it was faster,
as memory locations starts from 0.  I don't know if the trade off in
speed versus consistency with human conventions is as much as it was
before, but I think being a high-level language like Slate, it merits
consideration whether it makes more sense to tailor the language more
to human conventions or to computer conventions.

My argument would be, like David pointed out in his reply on this
topic, but slightly modified, consistency would favour staying with the
convention used by "humans".

-Bill Sun

--- Shaping <shaping at> wrote:
> > The whole "0-based" vs. "1-based" thing is misleading. When you are
> talking 
> > about "at:", you are locating some item in space by a coordinate -
> addressing. 
> > Memory is a spatial thing. Counting is just a different idiom
> entirely - 
> > searching. The thinking is, "I want that thing, there!", as opposed
> to, "Hmm, 
> > that's not what I want. Not that either. Oh, this one!"
> Discrete, /ordered/ items are countable.  Counting starts at 1.
> Fundamentally, this issue is about naming a thing with a number
> representing its 
> /place/ in an ordered sequence.  Order and counting both start at 1.
> Shaping
> >
> > Lee
> >
> > Shaping 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.  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.
> >>
> >>
> >> I have the same question/complaint, despite the slight improvement
> in 
> >> machine-efficiency it creates.  The convention produces much
> programmer 
> >> inefficiency--extra thinking/translating/checking.  Counting
> starts at 1.
> >>
> >>
> >> Shaping
> >>
> >>
> >
> > 

Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site! 

More information about the Slate mailing list