# use strict; use warnings; - Page 3

•  Subject
• Author
• Posted on

## Re: use strict; use warnings;

wrote:

PL/I can start array index at 1. Maybe Perl too.

## Re: use strict; use warnings;

But not all computer languages.

Dave

--
Dave Stratford - ZFCB
http://daves.orpheusweb.co.uk/

## Re: use strict; use warnings;

C     QUITE TRUE.                                                      000000100

--
Tim McDaniel, tmcd@panix.com

## Re: use strict; use warnings;

Whether or not you use the zeroth location, its available if you so wish...

John Black

## Re: use strict; use warnings;

Actually, everyone starts counting at zero.

For instance, how do you count apples in a basket?

If you use your fingers, for instance, you first close your fist, hiding all your
fingers. That's a zero. You are initializing a counter to zero.

This is when counting beings, not when the first item is noted.

Then, for each apple in the basket that has not been yet counted, you extend a finger,
and note that apple as counted.

(Starting with the middle finger, if there any "computer scientists" in the room who have
ever had anything to do with designing a language with 1 based arrays.)

If there are no apples in the basket, then there are no extended fingers: the count
remains at zero.

If you do not being counting at zero, you cannot correctly enumerate empty sets
and report that they have zero items.

In computer arrays, we use as the element index the count of the number of
direct and indirect predecessors which that element has in the sequence: how
many elements we have to skip or displace over to reach that item.

The indices represent a count: a count which does not include the indexed
element.

## Re: use strict; use warnings;

Considering 'counting begins before something was counted', every
human being on this planet must obviously be constantly counting
everything which can conceivably be counted, IOW, this definition has no
meaning.

It's also easily shown to contradict reality: Eg, 1914 was the first
year of the first world war but 1913 wasn't its zeroth year. By that
time, this was a future event nobody anticipated.

As I wrote in another posting: An array represents a general, surjective
function mapping elements from one set to elements of another set which
happens to be defined in tabular form. And programming languages which
insist that 'the natural order of things' is to start array indices with
1 and that only a dangerously deluded mind could want to come up with
anything different.

[...]

That's something which happens to be true in C because of the
equivalence of subscripting and pointer arithmetic and it has spread to
all kinds of other languages from there.

## Re: use strict; use warnings;

No, only this nonsensical interpretation thereof.

The manual for Lisp 1.5, dated 1962, describes arrays that are 0 based.

## Re: use strict; use warnings;

That's no interpretation. You wrote that 'counting begins before
something is actually counted'. That is during indeterminate period of time
before 'the first item is counted'. It's start can't be known, only its
end.

This doesn't contradict my statement. Also, on page 11, the IBM 704
FORTRAN manual states that

"The minimum value which a subscript may assume in the object
program is +1".

https://www.fortran.com/ibm.html

Not to mention the other example of "people on computing" who chose to
do differently than they monad collective named "Kaz Kylheku" which
chose to refer to itself as "we" "all of you" have chosen to ignore.

Since discussion with rabid cultists are pointless, I'm not going to
continue this.

## Re: use strict; use warnings;

That's no interpretation. You wrote that 'counting begins before
something is actually counted'. That is during indeterminate period of time
before 'the first item is counted'. It's start can't be known, only its
end.

This doesn't contradict my statement. Also, on page 11, the IBM 704
FORTRAN manual states that

"The minimum value which a subscript may assume in the object
program is +1".

https://www.fortran.com/ibm.html

Not to mention the other example of "people on computing" who chose to
do differently than they monad collective named "Kaz Kylheku" which
chose to refer to itself as "we" "all of you" have chosen to ignore.

## Re: use strict; use warnings;

Yes; it begins with the intent to count something, followed by the preparation:
initializing a counter to zero. These occur before the first item is noted
(if there exists a first item).

Yes it does; your statement clearly conveys (to a native English speaker) that
zero-based arrays originated in C, and spread to other languages.

(In Asperger English, maybe it doesn't.)

## Re: use strict; use warnings;

Yes, you are right.  Counting was the wrong situation.  We are talking about array indexing
and arrays are a collection of locations indexed by a number.  That number usually starts at
0.  Yes, you can avoid using that location if you so wish, but I'm talking about what is
almost always done in the computer industry.  Computer addresses (relative or absolute) are
the same kind of thing.  They start at 0.  The average person not in computers numbering
storage locations, like lockers, like parking spots, like mailslots, like a million examples,
does not start the indexing at 0 - they start at 1.  That's why I was saying its really not
relevent how people who are not in the computer industry number storage locations.  Its more
relevent how people who are in computers do it.

John Black

## Re: use strict; use warnings;

That number "doesn't usually start at 0". It starts at 0 in some
programming languages and at 1 in some others. In yet other programming
languages, any contiguous subset of the set of integers can be used as
array indices. In yet other languages, any ordered set (aka 'type') can
be used as index set.

## Re: use strict; use warnings;

says...

At one point (a long time ago) I thought that Perl did not need two different types of
arrays: list array vs. associative arrays.

a[5] = 100;
a[6] = "Hello";

seemed equivalent to the hash notation:

a = 100;
a = "Hello";

With a hash I could also do:

a = "Hello";

but that just made it seem like the hash was still the same thing but just allowed for more
flexible indexing (the index didn't have to be an integer).

But then I realized that a hash was not more general and was really just a different animal.
Because you can't do push, pop, shift, unshift, splice, etc. etc.  You can't do:

a to get the last element either.  Arrays are ordered lists and hashes are just content

John Black

## Re: use strict; use warnings;

[...]

That's how it works in 'some programming languages', prominent examples
would be PHP and AWK.

I think the easiest way to understand the different concepts in Perl is
to be aware of the fact that perl is something like a library sitting on
top of C. This means a Perl array is basically a C array, except that
its members are 'Perl objects' (scalars aka 'SV *'), that its memory is
managed automatically and 'some associated meta-information' is
maintained by the runtime, specifically, the current size. And 'a hash'
is just that: An associative array implemented as hash table using
separate chaining. Perl arrays are indexed in exactly the same way as C
arrays because this indexing is performed by C code working on C arrays
(I'm purposely ignoring \$[ here on the pretext that it never existed
:-).

But the same isn't necessarily true for other programming languages and
in the most general case, an array is 'some kind of data structure'
supposed to map (all) members of some kind of ordered set of discrete,
unique values to 'something else' (such a set is commonly called 'a
type' or 'a subtype' if it is a subset of another set). Eg, in Pascal,

var a: array [-23 .. 5] of integer

is an array of integers whose index type is a subtype of the type
'integer'. An index type can also be an enumeration, eg, assuming
the declarations

type animals = (cat, dog, bird, cow, platypus);
var livestock : array of [animals] of integer;

this would be valid assignment statements

livestock[platypus] := 10;
livestock[cow] := 5;

But livestock still has a first element, namely, livestock[cat] and
referring to that as the 'cath element' while the first element of the a
array would be called 'the -23rd element' and the first element of a
Perl array @a 'the zeroth element' (or, more correctly, 'the \$[th
element, followed by the '#[ + 1'th element
(hashmark-squareopenbracket-plus-one-th element) would just introduce an
open-ended set of different, context-dependent names for the same thing
(array element whose associated index is the smallest value in the index
set aka 'the first element').

## Re: use strict; use warnings;

JFTR: The original question/ claim was NOT about array indexing which is
- traditional limitations of C-derived languages notwithstanding - a
completely different animal, but about 'ordinals' assigned to items in a
sequence, specifically, that "the 1st item" would be the one with no
items in front of it, "the 2nd item" the one with one item in front of
it and so on, this being the usual convention based on counting items as
they appear in sequence and hence, that \$a[10] would be 'the eleventh
item of @a, as counted from the front'. Similarly, for an array @a of size
n, the element \$a[n - x] is the x-th item of @a when counting from the
back. There's an underlying, abstract concept called 'a sequence' here
which is useful in its own right.

## Re: use strict; use warnings;

On Mon, 03 Mar 2014 18:24:08 +0000, Rainer Weikusat

Sequence is also the first fundamental element of programming. It seems
so trivial compared to the other two, that programmers tend to disregard
its importance.

But any sequence of more than 3 steps is hard for humans to optimize.

That means programmers write a lot of sloppy programs. It also means
humans should leave DNA to God.

## Re: use strict; use warnings;

I've got a Dr Dawkins for you on line 3...

Ben

## Re: use strict; use warnings;

Dr Dawkins' personal system of unverifiable assumptions he holds to be
true isn't particularly interesting just because it is the system Dr
Dawkins is most comfortable with.

## Re: use strict; use warnings;

The practice of holding unverifiable assumptions to be true is precisely what
Dawkins is known for opposing.

## Re: use strict; use warnings;

wrote:

Without axioms there would be no math. But I think atheism is the wrong
axiom.

a) do I exist: pin prick, ouch.

b) does the universe exist: hmmm, look around.

c) does the universe exist without cause: ???

If so, why is there "something" rather than "nothing." Why does anything
exist at all? A natural "void," without any matter or energy, seems more
natural to me. Like starting from 0. :-)

So I believe the universe had a cause. But of course atheists must ask
"who created God?"

Einstein knew time is a property of the universe, the so called fourth
dimension. Human existence is limited by time and the spatial dimensions
of the universe. We cannot step outside that reality.

But God exists outside time itself. That's what "eternal" means. But in
programming terms, we may wonder, did God "bootstrap" his own existence?
I don't know.

It's obvious that humans of flesh and blood cannot exist outside time
itself. Since we cannot experience that condition, how can we possibly
understand it? Human intellectual capacity is limited, axiomatically so,
by the reality where we exist. We don't have sufficient reasoning power
to understand if God bootstrapped himself, or how.

Thus my remark about God and DNA. Studying DNA is one thing. Tampering
with it is another. Vengeance belongs to God.

I don't intend to fan the fire of atheism vs. faith. I was merely noting
that even great programmers should maintain humility. Certainly so, when
facing God.