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!aioe.org!5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Lower bounds of Strings Date: Wed, 13 Jan 2021 13:00:17 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <1cc09f04-98f2-4ef3-ac84-9a9ca5aa3fd5n@googlegroups.com> <37ada5ff-eee7-4082-ad20-3bd65b5a2778n@googlegroups.com> <26cac901-b901-4c4f-aba9-eab6cbd2a525n@googlegroups.com> <50f68100-8909-4fdb-ad26-14bcbc010775n@googlegroups.com> NNTP-Posting-Host: 5WHqCw2XxjHb2npjM9GYbw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:61113 List-Id: On 2021-01-12 23:56, Randy Brukardt wrote: > "Shark8" wrote in message > news:50f68100-8909-4fdb-ad26-14bcbc010775n@googlegroups.com... >> You mention the case where the difference in the indices is 1 as being >> separate; why? > > Because the "natural" implementation of the length of an array works when > the indices are one apart; you don't need extra code to deal with > String(1..0) - subtracting the bounds and adding 1 (the usual length > formula) works fine. Nothing prevents implementation from using one of the bounds and the length in the array's dope vector. It is a question of optimization. Then, maybe I am wrong, but I do not see anything that must prevent bounds on a null-array from sliding. They could slide to some canonical range making the "natural" implementation safe. >> Also, would the sometimes talked about idea of a "null range" have helped >> the situation out? >> (I don't think so, since the one is the required implementation, and the >> other is a syntax- and partially semantic-issue.) > > Right, the problem is that the syntax allows too much, and any rule to avoid > the problem necessarily will take code to make some sort of check. Syntax can never be the problem, only semantics can. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de