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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:6f07:: with SMTP id g7mr6568927qtv.308.1610624308619; Thu, 14 Jan 2021 03:38:28 -0800 (PST) X-Received: by 2002:a25:5c2:: with SMTP id 185mr9732404ybf.161.1610624308412; Thu, 14 Jan 2021 03:38:28 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.uzoreto.com!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 14 Jan 2021 03:38:28 -0800 (PST) In-Reply-To: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=94.31.101.133; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 94.31.101.133 References: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Lower bounds of Strings From: AdaMagica Injection-Date: Thu, 14 Jan 2021 11:38:28 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61118 List-Id: Stephen Davies schrieb am Dienstag, 5. Januar 2021 um 12:04:33 UTC+1: > I'm referring to the fact that any subprogram with a String > parameter, e.g. Expiration_Date, has to use something like > Expiration_Date (Expiration_Date'First .. Expiration_Date'First + 1) > to refer to the first two characters rather than simply saying > Expiration_Date (1..2). > > Not only is it ugly, but it's potentially dangerous if code uses the > latter and works for ages until one day somebody passes a slice instead > of a string starting at 1 (yes, compilers might generate warnings, > but that doesn't negate the issue, imho). 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. So why is the bad habit dangerous to think that the first element must have index one (or zero)? For me, this is a non sequitur.