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,1540032852ee6d61 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!attbi_s71.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Why does this work? (overloads) References: <1170823163.681564.186260@s48g2000cws.googlegroups.com> <1170881623.149455.139410@j27g2000cwj.googlegroups.com> <1170931228.165961.8170@m58g2000cwm.googlegroups.com> In-Reply-To: <1170931228.165961.8170@m58g2000cwm.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s71 1170960740 12.201.97.213 (Thu, 08 Feb 2007 18:52:20 GMT) NNTP-Posting-Date: Thu, 08 Feb 2007 18:52:20 GMT Organization: AT&T ASP.att.net Date: Thu, 08 Feb 2007 18:52:20 GMT Xref: g2news2.google.com comp.lang.ada:9156 Date: 2007-02-08T18:52:20+00:00 List-Id: 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 := B > (correct?) and vice versa. My Pascal trick had neither of these > problems yet carried boundary checking using either name. Right. But your Pascal trick is an abomination. You can do the same thing in Ada using overlays, but it's not recommended. There's probably also a way with access types. Something like (not tested) type Vector is array (Natural range <>) of Real; Max : constant := ...; subtype Zero_Based is Vector (0 .. Max - 1); subtype One_Based is Vector (1 .. Max ); type Zero_Ptr is access all Zero_Based; type One_Ptr is access all One_Based; V : aliased Zero_Based; ZP : Zero_Ptr := V'access; function To_One is new Ada.Unchecked_Deallocation (Source = Zero_Ptr, Target => One_Ptr); OP : One_Ptr := To_One (ZP); I wouldn't recommend it. -- Jeff Carter "What I wouldn't give for a large sock with horse manure in it." Annie Hall 42