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!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.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: class wide iterable (and indexable) Date: Tue, 22 Jan 2019 16:00:18 -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:00:19 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="7075"; 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:55327 Date: 2019-01-22T16:00:18-06:00 List-Id: "Dmitry A. Kazakov" wrote in message news:q26lsh$1ee3$1@gioia.aioe.org... > On 2019-01-22 00:15, Randy Brukardt wrote: >> 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). > > I disagree. It would make array slices more difficult to use. Array slices as defined in Ada aren't worth the substantial implementation complexity. I would replace them by slicing functions, and the bounds are lost. > Presently we can do things like > > Read (Buffer (From..To), Last); Surely. But "Last" is a weird Ada-ism that exists solely because array bounds are so generally accessible. It is much more natural (and sensible for most uses) to return the count of characters read. > Foo can move the index Last and this is the same index as outside in the > caller because indices do not slide. If you make the lower bound fixed, > indices would slide and that would require a lot of index arithmetic upon > calling subprograms on slices. This would be far more error-prone than > occasionally forgetting to use Buffer'First instead of 1. True, in the rare case where that matters. But most of the time, one has to do that math to convert "Last" into a number of character read. So this is a wash to me - some things are easier, som things are harder. (Again, "Last" is an odd Ada-ism, specs would return a character count, not some array index.) Randy.