From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.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: class wide iterable (and indexable) Date: Tue, 22 Jan 2019 16:02:32 -0600 Organization: JSA Research & Innovation Message-ID: References: <2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com> <75328dc5-fc59-4228-b77e-77ba6e5101c3@googlegroups.com> Injection-Date: Tue, 22 Jan 2019 22:02:33 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="7091"; 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; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:55328 Date: 2019-01-22T16:02:32-06:00 List-Id: "Jeffrey R. Carter" wrote in message news:q27if9$b0r$1@dont-email.me... > On 1/22/19 12:15 AM, Randy Brukardt wrote: >> >> Moreover, in a new Ada-like language, it would make the most sense to >> completely unify containers and arrays, which would mean that arrays >> would >> be more like Vectors than like Ada arrays. For instance, in a Vector, the >> lower bound is fixed for all values of a particular type. That would >> eliminate a lot of programming errors that happen in Ada programs (many >> programs fail to deal with unusual lower bounds, because it's hard to get >> right). > > Ada has always had the ability to define array-like types with a fixed > lower bound: > > type String_From_1 (Length : Natural) is record > Value : String (1 .. Length); > end record; > > I use such constructs when appropriate (in mathematics, for example, > matrices and vectors have indices with lower values of 1, and a decent > implementation should reflect and enforce that). One might argue that the > reason they're not used more often is because of the value of having array > types with variable lower bounds, but I doubt it. They're not used more often because this fixes the length, and prevents operations on items with different lengths. Again, a string is not an array -- a Vector is a better model for a string. Randy.