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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,43bc631fb4a56c2a X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-07 06:22:35 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!news.ksw.feedmania.org!newsfeed.mesh.ad.jp!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: <9fnbtt$ild$1@e3k.asi.ansaldo.it> Subject: Re: Unchecked_Conversion Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Thu, 07 Jun 2001 09:21:47 EDT Organization: http://www.newsranger.com Date: Thu, 07 Jun 2001 13:21:47 GMT Xref: archiver1.google.com comp.lang.ada:8313 Date: 2001-06-07T13:21:47+00:00 List-Id: In article <9fnbtt$ild$1@e3k.asi.ansaldo.it>, Lele says... >I should convert data types and record data types from one type to another, Just to back up Marc here, you should almost *never* have to convert types. The only times I ever have to do it are when interfacing with external routines that expect to deal with untyped buffers of data (even then you can usually just pass the routine the 'address and ('size + 7)/8 of your object). Just about any other instance of a conversion represents a design failure on someone's part, which should be rectified the right way: by comming up with a common type that works for everyone and rewriting the code to work with it. What exactly are you doing that you think you need to convert types for? >not violate the assumptions of the rest of the program. Are there particular >risks about using Unchecked_Conversion? Is it a better approach the address >attribute? The main problem with Unchecked_Conversion is that its a function. That means most of the time its used, a transfer of the data will occur. (The execption being when its used as a parameter). For a large structure this could be a problem. The way around it is to either only use it in parameters, or to Unchecked_Convert access types instead of the actual types. Now there are some risks associated with Unchecked_Converson on access types. Some access types are more that just simple addresses. For example, an access type for an unconstrained array may also contain information about the array's bounds so that constraint checks on array indexes can occur. So in some situations two access types may not be safely convertable. You'd have to check your compiler docs to find out what restrictions on Unchecked_Conversion exist. That being said, I *always* perfer this technique over the "for use at" clause. I think its much less dangerous for the *reader*. When pointers are involved, you expect that there can be ailiasing of the accessed data. But when simple variable names are used, you do not generally expect the possibility that there could be ailiasing. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com