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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ac407a2a34565a9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.227.166 with SMTP id sb6mr3586305pbc.4.1331165313153; Wed, 07 Mar 2012 16:08:33 -0800 (PST) MIME-Version: 1.0 Path: h9ni51479pbe.0!nntp.google.com!news1.google.com!goblin1!goblin3!goblin.stu.neva.ru!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Wed, 7 Mar 2012 18:08:28 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1331165311 9521 69.95.181.76 (8 Mar 2012 00:08:31 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 8 Mar 2012 00:08:31 +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 Date: 2012-03-07T18:08:28-06:00 List-Id: "Robert A Duff" wrote in message news:wccpqcxrzj2.fsf@shell01.TheWorld.com... ... > Actually, I just realized there's a workaround for the slice problem. Yes, as I just posted. I guess I should have read further before answering. > The following does not raise any exception. > > procedure Array_Test is > > type Integer_Array is array (Positive range <>) of Integer > with Dynamic_Predicate => Integer_Array'First = 1; > > procedure Foo (Param : in out Integer_Array) is > begin > null; > end Foo; > > A : Integer_Array (1 .. 10) := (others => 0); > > subtype Slide is Integer_Array(1..6); > begin > Foo (Slide(A (3 .. 8))); > end Array_Test; > > But that's kind of tricky; I wouldn't do that without copious > comments. And some constants or something to avoid violating > the DRY principle. Maybe it's tricky, buit I've used it a lot, especially inside of things like Ada.Strings.Fixed (and in my spam filter, which tends to do direct string manipulations because it's usually easier to do that than to figure out what Ada.Strings.Fixed function does 80% of the job [none of them ever seem to do the whole job] and then figure out how to do the rest afterwards). But typically, "Slide" uses bounds derived from whatever you're going to pass (usually, "3" and "8" above are local variables anyway): declare L : Natural := 3; R : Natural := 8; -- These are usually calculated from the other code nearby. subtype Slide is Integer_Array(1..R-L+1); begin Foo (Slide(A (L .. R))); end; Feel free to turn this into a "gem" if you're so inclined. :-) Randy.