Path: ...!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.arch Subject: Re: is Vax addressing sane today Date: Wed, 25 Sep 2024 21:12:50 +0300 Organization: Tidorum Ltd Lines: 58 Message-ID: References: <2024Sep6.080535@mips.complang.tuwien.ac.at> <2024Sep8.155511@mips.complang.tuwien.ac.at> <73c6d21457c487c61051ec52fe25ea5d@www.novabbs.org> <09ce1622b872f0b0fa944e868a8c97be@www.novabbs.org> <20240925200745.0000590f@yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net KiyjTjFshdJM+1ho9C49fwRV250drOB8s9+nDIBbn/4rYcCd6J Cancel-Lock: sha1:nkajmNzADOr0BjDDMtym0B0uYjg= sha256:n74ZLpLD5a7mD9yb/IoGAxnbepvy62I8wHk58IdtdwU= User-Agent: Mozilla Thunderbird Content-Language: en-US In-Reply-To: Bytes: 4236 On 2024-09-25 20:30, MitchAlsup1 wrote: > On Wed, 25 Sep 2024 17:07:45 +0000, Michael S wrote: > >> On Wed, 25 Sep 2024 09:54:17 -0700 >> Stephen Fuld wrote: >> >>> On 9/10/2024 1:13 AM, Niklas Holsti wrote: >>> >>>> In the Ada case, the ability to declare array types with >>>> programmer- chosen index types with bounded range, such as >>>> range-bounded integers or enumerations, means that the compiler can >>>> avoid indexing checks when the (sub)type of the index is known at >>>> compile time to fit within the index range of the array. >>> >>> I have always liked the idea of variable ranges able to be specified >>> in the language.  Besides the advantages you mentioned, it provides >>> more human "comprehensibility" (if the ranges are reasonably named) >>> i.e. better internal documentation, and it makes responding to >>> specification changes required later in the program life cycle easier >>> and less error prone, i.e. if the range has to change, you change it >>> in one place and don't risk missing making the change in some obscure >>> part of the program you forgot about. >>> >>> >> >> The problem here is that arrays with fixed bounds were common when >> Ada was conceived back in the mid 1970s. On general-purpose (as opposed >> to embedded) computers they were already much rarer when Ada was shipped >> in 1983. By late 1990s arrays with fixed bounds were rare exception >> rather than rule. > > It sounds like variable ranges (array indexes) would be becoming more > common, also. > > Where "variable range" is a variable that is defined to have a > specified range, but from run to run the upper and lower bounds > can be modified without re-compilation. Ada subtypes can do that, but the underlying type, set at compile time, for example the standard Integer type, will put an upper bound on the range of the subtype. The number of bits in the numbers cannot change without recompilation. Michael S says that arrays with variable bounds are becoming more common. I assume he means indexable containers, often called vectors. Ada has several such containers in the standard library, all defined as generic in the index subtype, which means that the compiler can check that the type of a vector index is correct. If a vector is allocated (sized) with a certain (dynamically defined) length, instead of growing element by element, and if that length matches the (dynamically defined) range of the index subtype, the same static checking methods/proofs can be applied as for traditional arrays of fixed size. I think that the current tools don't do that for vector containers by default, but I beliveve they can be persuaded to do it by writing the corresponding preconditions for the indexing operations.