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!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Lower bounds of Strings Date: Tue, 12 Jan 2021 16:56:34 -0600 Organization: JSA Research & Innovation 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> Injection-Date: Tue, 12 Jan 2021 22:56:35 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="9584"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:61112 List-Id: "Shark8" wrote in message news:50f68100-8909-4fdb-ad26-14bcbc010775n@googlegroups.com... > On Tuesday, January 12, 2021 at 1:12:35 AM UTC-7, Randy Brukardt wrote: >> "Shark8" wrote in message >> news:26cac901-b901-4c4f >> On Friday, January 8, 2021 at 7:31:40 PM UTC-7, Randy Brukardt wrote: >> ... >> > >Can you give some examples here? >> > All of the super-null nonsense occurs because of slices, which slows >> > down >> > any code that uses them. >> What do you mean "super-null" nonsense? >> Any range that is null is treated as the same by Ada. Any null range >> where >> the bounds are more than 1 apart is known as a "super-null" range. For >> instance, one typically writes: >> >> N : String(1..0) >> >> to define a null string object. But you can write *any* null range here: >> >> N2 : String(314 .. 25); >> >> And it takes code to figure this out at runtime if either bound is >> nonstatic >> (which is usually the case with slices). And you still have to store the >> bounds (you can still ask for the bounds of N2, and one better get 314 >> and >> 25, but the length is still zero). And N = N2, so compares are >> complicated >> (one has to check the length, but that's more expensive to figure out >> than >> just a subtract). You end up generating a lot of code to deal with a >> rather >> unlikely case. > I understand now. > 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. > 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. ... Randy.