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!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Array index overloading Date: Thu, 7 Aug 2014 00:17:12 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <03d102e1-1c2f-4056-82d5-3eaaaffbb0f1@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1407388632 19823 69.95.181.76 (7 Aug 2014 05:17:12 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 7 Aug 2014 05:17:12 +0000 (UTC) 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.6157 Xref: news.eternal-september.org comp.lang.ada:21502 Date: 2014-08-07T00:17:12-05:00 List-Id: "Peter Chapin" wrote in message news:ppKdnfmkdIYX-n_ORVn_vwA@giganews.com... > On 2014-08-06 12:47, marmaduke.woodman@univ-amu.fr wrote: > >> Handling index arrays and generating an output array is something I can >> write, so my question is if the syntax can be overloaded, or I should >> expect to implement an explicit "slice" function? > > As Pascal mentioned one dimensional array slices are supported in Ada by > just indexing using notation A(I .. J) for array A. If you want > non-unity strides, or multi-dimensional slices, or some other fancier > effects, you will need to turn to a library of some kind. > > Although as I write this I'm wondering if a subtype with a static > predicate could cover some of those bases. Hmm. You'll find that it is illegal to declare an array with an index subtype that has one or more predicates. We didn't want compilers to have to support "holey" arrays or slices. One could create a container that supported almost any sort of indexing that someone wanted. In particular, the Map containers support using the indexed notation on the Key_Type, and the Key_Type can be pretty much anything you want, so long as it is non-limited. So, with appropriate declarations, you can write: Storage ("Bob") := Obj1; Storage ("Randy") := Obj2; if Storage ("Tuck") = Storage ("Randy") then ... and so on. Randy.