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!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: class wide iterable (and indexable) Date: Wed, 23 Jan 2019 09:14:16 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com> <75328dc5-fc59-4228-b77e-77ba6e5101c3@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.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; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.8.3 Xref: reader01.eternal-september.org comp.lang.ada:55330 Date: 2019-01-23T09:14:16+01:00 List-Id: On 2019-01-22 23:00, Randy Brukardt wrote: > "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. The reverse. A container without slices is half useless to me. BTW, nD arrays must support slicing, subarrays, subplanes etc. >> 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. No, because it is a break of the abstraction, unsafe and error-prone. >> 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.) You want to get rid of indices and have only positions. Positions is not a substitute to indices. With multiple interfaces there would be no problem to have a positional view on the array. Which is not an array interface anymore. It would be an interface of a tuple. Ada does not have builtoin tuples, but it could have them. Just do not force everything into it. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de