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,5d708145f98f6273 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-14 10:37:50 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread1.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Access type conversions, how? References: <107mgcjspsour11@corp.supernews.com> <407c0f2c.0@entanet> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Wed, 14 Apr 2004 17:37:50 GMT NNTP-Posting-Host: 63.184.1.108 X-Complaints-To: abuse@earthlink.net X-Trace: newsread1.news.pas.earthlink.net 1081964270 63.184.1.108 (Wed, 14 Apr 2004 10:37:50 PDT) NNTP-Posting-Date: Wed, 14 Apr 2004 10:37:50 PDT Xref: archiver1.google.com comp.lang.ada:7101 Date: 2004-04-14T17:37:50+00:00 List-Id: Robert I. Eachus wrote: > > Then you need to (unchecked) convert the access type, not the data. Of > course, make sure that both access types are either declared access all, > or designate objects in the same storage pool. It seems to me that we may be overcomplicating this problem. The OP wants to store values using an application-suitable floating-point type, but pass a pointer to a value of a similar, but library-dependent floating-point type to an operation of the library. This is primarily a problem of abstraction, not of access type conversion. At the lowest level, you have the library, which may differ by platform, but which offers similar functionaility on all platforms. In the middle, you have a wrapper, which takes parameters of application-suitable types, and calls the library operations. Any necessary conversions occur here. The operations of the wrapper may be inlined if measurements show that timing requirements cannot be met otherwise. At the highest level, you have the application which uses application-suitable types and call the operations of the wrapper. So we have something like: Library: type LDFPT is digits ...; -- Library-Dependent Floating-Point Type function LF (Value : access LDFPT) return ...; Application: type ASFPT is digits ...; -- Application-Suitable Floating-Point Type F : ASFPT; Wrapper: function WF (Value : ASFPT) return ...; -- Calls LF The application makes the call WF (F); The body of WF would look something like function WF (Value : ASFPT) return ... is L : aliased LDFPT := LDFPT (Value); begin -- WF return LF (L'Unchecked_Access); end WF; This version doesn't allow the library to change Value, but that can easily be arranged if needed. The important thing about this approach is that the application doesn't have to alias variables simply because a library needs pointers to values. You can more easily have different versions for different libraries, simply by having different bodies for the wrapper. -- Jeff Carter "Blessed are they who convert their neighbors' oxen, for they shall inhibit their girth." Monty Python's Life of Brian 83