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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1540032852ee6d61 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!cleanfeed2-a.proxad.net!nnrp16-1.free.fr!not-for-mail Return-Path: Date: Thu, 08 Feb 2007 13:05:22 +0100 From: "Grein, Christoph (Fa. ESG)" Subject: AW: Why does this work? (overloads) In-reply-to: <1170931228.165961.8170@m58g2000cwm.googlegroups.com> To: comp.lang.ada@ada-france.org MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft Exchange V6.5 Content-Type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable Content-class: urn:content-classes:message Thread-topic: Why does this work? (overloads) Thread-index: AcdLbyVkAqt1tNCnSnS1OhG6YL1q/gACWmQg X-OriginalArrivalTime: 08 Feb 2007 12:05:23.0972 (UTC) FILETIME=[69B19440:01C74B79] X-Virus-Scanned: amavisd-new at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.9rc1 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.ada Message-ID: X-Leafnode-NNTP-Posting-Host: 88.191.17.134 Organization: Guest of ProXad - France NNTP-Posting-Date: 08 Feb 2007 13:10:02 MET NNTP-Posting-Host: 88.191.14.223 X-Trace: 1170936602 news-2.free.fr 30475 88.191.14.223:53062 X-Complaints-To: abuse@proxad.net Xref: g2news2.google.com comp.lang.ada:9136 Date: 2007-02-08T13:10:02+01:00 Try this. Not very elegant, but works. with Ada.Exceptions; with Ada.Text_IO, Ada.Float_Text_IO; use Ada.Text_IO, Ada.Float_Text_IO; with Ada.Unchecked_Conversion; procedure Test_it is N: constant :=3D 10; type Vector is array (Integer range <>) of Float; -- Fat pointers don't work (include bounds). -- type Vector_Ptr is access all Vector; -- subtype Vector_Ptr_1 is Vector_Ptr ( 1 .. N ); -- subtype Vector_Ptr_101 is Vector_Ptr (101 .. N + 100); -- Thin pointers (don't include bounds): type Vector_Ptr_1 is access all Vector ( 1 .. N ); type Vector_Ptr_101 is access all Vector (101 .. N + 100); function Convert is new Ada.Unchecked_Conversion (Vector_Ptr_1, Vector_Ptr_101); X: aliased Vector (1 .. N); -- constrained nominal subtype P: Vector_Ptr_1 :=3D X'Access; Q: Vector_Ptr_101 :=3D Convert (P); begin for i in X'Range loop X (i) :=3D Float (i); end loop; for i in P'Range loop Put (Integer'Image (i)); Put (P (i)); New_Line; end loop; for i in Q'Range loop Put (Integer'Image (i)); Put (Q (i)); New_Line; end loop; exception when Exc: others =3D> Put_Line ("Unexpected exception " & Ada.Exceptions.Exception_Name (Exc)); end Test_it; -----Urspr=FCngliche Nachricht----- Jerry wrote: Good point. However, it uses twice the memory, and worse, changes made in A are not reflected in B without repeating the assignment A :=3D B (correct?) and vice versa. My Pascal trick had neither of these problems yet carried boundary checking using either name. Maybe there's a way to do this using unrestricted_access variables of GNAT. Jerry