From mboxrd@z Thu Jan 1 00:00:00 1970 From: krewat@kilonet.net (Arthur Krewat) Date: Thu, 8 Jun 2017 09:55:49 -0400 Subject: [TUHS] Array index history In-Reply-To: <1496929789.1143160.1002957384.3AD574C4@webmail.messagingengine.com> References: <23afd785-e260-75ca-5c46-77c62fbcf3cd@kilonet.net> <016301d2dfc0$b098e250$11caa6f0$@ronnatalie.com> <57dce8ab-153d-89ce-91d6-07d9f01f7d6b@kilonet.net> <1496929789.1143160.1002957384.3AD574C4@webmail.messagingengine.com> Message-ID: On 6/8/2017 9:49 AM, Random832 wrote: > On Wed, Jun 7, 2017, at 15:15, Arthur Krewat wrote: >> 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. > Shortly after making that statement, it occurred to me that the preprocessor or assembler could take care of that easily. Even better than worrying about whether arrays started at 0 or 1 in C would be to institute bounds checking in the first place :) But again would add lots of extra code that in the days of the origins of C was not something you wanted to add to the memory footprint.