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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,af3dada69080e420 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-24 03:08:43 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!news.gtei.net!newsfeed!news.tele.dk!news.tele.dk!small.news.tele.dk!news-FFM2.ecrc.net!news.iks-jena.de!not-for-mail From: Lutz Donnerhacke Newsgroups: comp.lang.ada Subject: Re: Interesting effects in array renaming Date: Tue, 24 Jun 2003 10:08:43 +0000 (UTC) Organization: IKS GmbH Jena Message-ID: References: <3EF5E6B8.3030203@spam.com> <3EF7B8CC.3000100@attbi.com> NNTP-Posting-Host: taranis.iks-jena.de X-Trace: branwen.iks-jena.de 1056449323 23631 217.17.192.37 (24 Jun 2003 10:08:43 GMT) X-Complaints-To: usenet@iks-jena.de NNTP-Posting-Date: Tue, 24 Jun 2003 10:08:43 +0000 (UTC) User-Agent: slrn/0.9.7.4 (Linux) Xref: archiver1.google.com comp.lang.ada:39646 Date: 2003-06-24T10:08:43+00:00 List-Id: * Dmitry A. Kazakov wrote: > It povides additional safety for the reader of a program. [Isn't a goal Ada > design?] It would allow to omit range checks many cases like: > > procedure Sum (L : in out Vector; R : Vector) is > subtype Of_L is Vector (L'Range); > RR : Of_L renames R; -- Checked here > begin > for I in L'Range loop > L (I) := L (I) + RR (I); -- No range check needed Currently this is not the case: $ cat > test.adb <) of Integer; procedure Sum (L : in out Vector; R : Vector) is subtype Of_L is Vector (L'Range); RR : Of_L renames R; -- Checked here begin for I in L'Range loop L (I) := L (I) + RR (I); -- No range check needed end loop; end Sum; a : Vector := (4 .. 10 => 4); b : Vector := (1, 2, 3); begin Sum(a, b); end Test; END $ gnatmake test gcc -c test.adb gnatbind -x test.ali gnatlink test.ali gnatlink: warning: executable name "test" may conflict with shell command $ ./test raised CONSTRAINT_ERROR : test.adb:10 $ sed -n 10p test.adb L (I) := L (I) + RR (I); -- No range check needed $ _