From mboxrd@z Thu Jan 1 00:00:00 1970 From: random832@fastmail.com (Random832) Date: Thu, 08 Jun 2017 09:49:49 -0400 Subject: [TUHS] Array index history In-Reply-To: <57dce8ab-153d-89ce-91d6-07d9f01f7d6b@kilonet.net> References: <23afd785-e260-75ca-5c46-77c62fbcf3cd@kilonet.net> <016301d2dfc0$b098e250$11caa6f0$@ronnatalie.com> <57dce8ab-153d-89ce-91d6-07d9f01f7d6b@kilonet.net> Message-ID: <1496929789.1143160.1002957384.3AD574C4@webmail.messagingengine.com> On Wed, Jun 7, 2017, at 15:15, Arthur Krewat wrote: > On 6/7/2017 3:03 PM, Ron Natalie wrote: > >> Why go to the trouble of decrementing the index to retreive the first entry? > > What makes you think that you have to decrement the index. Don't get sucked up in the idiotic C implementation of an array. Arrays can be efficiently implemented no matter where the index starts. > > In the days when memory and clock cycles were costly, an extra decrement > or subtract was not something to be taken lightly :) You wouldn't need a decrement per access, because the base itself could still be stored as the address of the "0th" element (i.e. what would be the "-1th" in a 0-based system). It might add some extra complexity to the relocator, if it's not currently possible to have a reference outside the bounds of an object and/or with a negative offset, but statically linked programs (the only kind on V7 and earlier) did not do any runtime relocation.