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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cef1e23795181e0c X-Google-Attributes: gid103376,public From: robert_dewar@my-dejanews.com Subject: Re: Alternate to Unchecked_Conversion - Portable? Date: 1999/02/25 Message-ID: <7b2leu$ad$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 448174503 References: <36d05e39.0@news.pacifier.com> <36d2638e.6427631@nntp.concentric.net> <7avpi0$jke$1@nnrp1.dejanews.com> <36d3bf1f.1891152@nntp.concentric.net> X-Http-Proxy: 1.0 x6.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Thu Feb 25 05:01:23 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-02-25T00:00:00+00:00 List-Id: In article <36d3bf1f.1891152@nntp.concentric.net>, cjrgreen@concentric.net (Christopher Green) wrote: > Unchecked conversion of C pointers to Ada access values > is, in my experience, no more portable than using address > clauses to alias structured types. When the desired Ada > object is an instance of an unconstrained type, > converting a pointer is completely nonportable and > usually impractical. and also completely meaningless! An unconstrained array pointer in Ada must have bounds, and these bounds must come from somewhere. It is not just that this attempted conversion is non-portable, it is semantic nonsense. There are two possible approaches that are likely to be portable in practice and which make semantic sense. If you know the bounds, e.g. they are implied by the logic or by some other parameters that are passed, then you can declare a local subtype of the array type with the right bounds, and use a pointer to this constrained type. If you don't know the bounds, then use a "big array" type such as subtype Big_String is String (Positive); type Big_String_Ptr is access Big_String; now of course once you get a value of type Big_String_Ptr using Unchecked_Conversion, it is up to you not to access the array value outside its real bounds, but there is no magic to prevent this in this case! -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own