Some questions on Slate syntax
Shaping
shaping at earthlink.net
Fri Apr 1 21:51:11 PST 2005
----- Original Message -----
From: "David Hopwood" <david.nospam.hopwood at blueyonder.co.uk>
To: "Slate project discussion" <slate at tunes.org>
Sent: Sunday, March 27, 2005 10:08
Subject: Re: Some questions on Slate syntax
> Shaping wrote:
>> Lee Salzman 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.
>
> Yes, I agree that spatial metaphors are most appropriate for arrays
> and indexing. Think of the index as corresponding to a distance from
> the start of the sequence, and as pointing to the left [*] of the item
> being indexed:
>
> 0 1 2 3 4
> +---+---+---+---+
> | | |XXX| |
> +---+---+---+---+
>
> <---2--->
>
>
> For intervals, use the half-open convention and think of the bounds
> as being the left and right sides of the bounded interval, e.g. for
> the interval [1,3):
>
> 0 1 2 3 4
> +---+---+---+---+
> | |XXX|XXX| |
> +---+---+---+---+
>
> <-1->
> <-----3----->
>
>
> [*] for people used to left-to-right languages.
>
>> Order and counting both start at 1.
>
> Natural numbers start at 0.
Natural numbers start at 1. The occasional reference to 0 as one of the natural
numbers is a mistake, and fortunately does not often happen. Zero is a
radix-representational convenience, and, as such, is very useful. But you do
not need it to model anything.
Counting as a perceptual act starts with one. You cannot count zero things. To
do so in a nonaction.
>
> Bill Sun wrote:
> > Furthermore, when counting, of course it would start at the first
> > natural number.
>
> which is 0. You're probably thinking of "ordinal numbers".
>
> > 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.
>
> There's nothing "natural" about either way (the technical meaning
> of "natural number" notwithstanding); they're just conventions.
Index from 0 and indexing from 1 are not just conventions. Perception begins at
one, not at zero. You are confusing mental inventions with observations.
> If you're used to the 0-based convention, then you think of the element
> at 0-based index n as being element n, and don't think about the
> "n-th element" at all.
>
> > 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.
>
> 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.)
Consider not forcing the human to follow the machine; make the machine
architecture follow the human in natural order.
Shaping
More information about the Slate
mailing list