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 02:12:33 -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> Injection-Date: Tue, 12 Jan 2021 08:12:34 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="21576"; 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:61106 List-Id: "Shark8" wrote in message news:26cac901-b901-4c4f-aba9-eab6cbd2a525n@googlegroups.com... 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. One of the reasons for suggesting using the bounded vector as a model is all of this sort of stuff vanishes, as the lower bound never changes in the vector packages. Only the upper bound moves, which is what is needed the vast majority of the time. Both the early Pascal compilers we used in the very early days of Janus/Ada, and Janus/Ada itself, used a form of bounded strings rather than the more complex Ada model. (The CS 701 language that we originally were tasked to implement used bounded strings, and we kept it on our early commercial compilers so we could concentrate on other functionality like packages and private types.) That was a lot easier to use than the Ada model, it was a huge adjustment to switch to the Ada form and it bloated the code as well. Randy.