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.189.197 with SMTP id gk5mr908999pbc.1.1330586179011; Wed, 29 Feb 2012 23:16:19 -0800 (PST) Path: h9ni25826pbe.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!85.214.198.2.MISMATCH!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Thu, 01 Mar 2012 08:16:18 +0100 Organization: A noiseless patient Spider Message-ID: <87mx80x03h.fsf@ludovic-brenta.org> References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="CT+A2vVI6Jowh2NBmCZYXA"; logging-data="9372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX186dr8O1BAgK786Cai1p9Nv" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:sb0PQea/D3nINbgzbz1t9v+nrCk= sha1:+G6prC3WRn6Gl9koZvjNgOhK1Ks= Content-Type: text/plain; charset=us-ascii Date: 2012-03-01T08:16:18+01:00 List-Id: Robert A Duff writes on comp.lang.ada: > Robert A Duff writes: > >> % ./array_test >> >> raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : predicate failed at array_test.adb:14 > > Actually, I just realized there's a workaround for the slice problem. > 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))); Doesn't that involve copy-in and copy-out between the slice and a temporary object of type Slide? Grossly inefficient, methinks. > 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. Yes. For Adam: DRY=Don't Repeat Yourself. -- Ludovic Brenta.