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=0.8 required=3.0 tests=BAYES_50,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.5-pre1 X-Received: by 2002:ac8:4705:: with SMTP id f5mr73342431qtp.37.1609844672063; Tue, 05 Jan 2021 03:04:32 -0800 (PST) X-Received: by 2002:a25:6ec3:: with SMTP id j186mr114006792ybc.165.1609844671864; Tue, 05 Jan 2021 03:04:31 -0800 (PST) Path: eternal-september.org!reader02.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 5 Jan 2021 03:04:31 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=20.133.0.13; posting-account=YRfoYAoAAADhSEO2nLYx10QUUvp8akYl NNTP-Posting-Host: 20.133.0.13 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> Subject: Lower bounds of Strings From: Stephen Davies Injection-Date: Tue, 05 Jan 2021 11:04:32 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:61035 List-Id: I'm sure this must have been discussed before, but the issue doesn't seem to have been resolved and I think it makes Ada code look ugly and frankly reflects poorly on the language. 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). There must be many possible solutions, without breaking compatibility for those very rare occasions where code actually makes use of the lower bound of a string. e.g. Perhaps the following could be made legal and added to Standard: subtype Mono_String is String (1 .. <>); One question with this would be whether or not to allow procedure bodies to specify parameters as Mono_String when the corresponding procedure declaration uses String.