From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Lower bounds of Strings Date: Thu, 14 Jan 2021 15:02:24 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 14 Jan 2021 14:02:26 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="6b4057ac66baa89617cc8858f74d9532"; logging-data="18290"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19DXQELXojAlzh0LKSHdzOroqpsd6eCx7o=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 Cancel-Lock: sha1:kCBqUOiid/PRH6AIn5wCQVaAEN4= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61124 List-Id: On 1/14/21 12:38 PM, AdaMagica wrote: > > I really do not see the problem here. If I want the first element, I write X(X'First). > Where's the problem? > > In his paper about model railroads > http://www.cs.uni.edu/~mccormic/RealTime/ > John McCormick came to the conclusion that one of the reasons why Ada was so successful was the fact that indices had not to start with 0 resp. 1, i.e. they may bear meaning. In such cases, it is absolute nonsense to slide slices to the first index value. > > Also for enumeration indices, sliding does not make sense. The trouble is that this is not really discussing arrays. It's discussing sequences, implemented by arrays, such as String. 1-D arrays are often used to implement sequences. In arrays used as sequences, the indices are meaningless, and slicing, sliding, and sorting are often appropriate. As the indices are meaningless, it makes sense for them to be integers with a fixed lower bound of 1, since that is how we typically talk about positions in sequences. However, there are also many cases when it's useful to be able to have slices of sequences with a different lower bound, so remembering to use 'First is still important. Array types used as sequences are often unconstrained. The other use ofarrays (1- and multidimensional) is as maps. In arrays as maps, the indices are meaningful, and slicing, sliding, and sorting are usually inappropriate. Array types used as maps are usually constrained. Ada's Vector containers are really variable-length sequences. In designing a new language, it might be useful to keep these two concepts separate. -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus 22