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,c6acbb9f2027b8c9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!z14g2000cwz.googlegroups.com!not-for-mail From: "REH" Newsgroups: comp.lang.ada Subject: Re: volatile vs aliased Date: 6 Oct 2005 06:40:36 -0700 Organization: http://groups.google.com Message-ID: <1128606036.713575.3990@z14g2000cwz.googlegroups.com> References: <1128525722.605730.281980@g43g2000cwa.googlegroups.com> <87mzlnomca.fsf@ludovic-brenta.org> NNTP-Posting-Host: 192.91.173.36 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1128606042 2401 127.0.0.1 (6 Oct 2005 13:40:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 6 Oct 2005 13:40:42 +0000 (UTC) In-Reply-To: User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: z14g2000cwz.googlegroups.com; posting-host=192.91.173.36; posting-account=lnUIyw0AAACoRB2fMF2SFTIilm8F10q2 Xref: g2news1.google.com comp.lang.ada:5449 Date: 2005-10-06T06:40:36-07:00 List-Id: Randy Brukardt wrote: > This seems like a good time to mention that I think the explicit use of > System.Address in Ada 95 and Ada 200Y code is usually a mistake. Since > pragma Convention can be used to ensure that general access types have the > appropriate representation, its rare that Address needs to be used for > interfacing. (There is only a handful of uses of Address in Claw, for > example.) > > Moreover, when you *do* need to use it, Address_to_Access_Conversions is the > best way to convert it, not an overlay (which at best blocks optimizations > and at worst won't even work right). > > type T is ...; > > procedure Read_Variable (At_Address : in System.Address; > Into : out T) is > package AAC is new System.Address_to_Access_Conversions (T); > V : AAC.Object_Pointer := AAC.To_Pointer (At_Address); > begin > -- perform my own explicit validation of the pointer's contents, perhaps > -- using 'Valid; then, copy into Into: > Into := V.all; > end Read_Variable; > > But it is better still to declare an appropriate type and never use Address > in the first place: > > type Pointer_T is access all T; > pragma Convention (C, Pointer_T); > > Address clauses should be restricted to mapping to hardware, IMHO. > > Randy. Randy, That's good stuff. Will it still apply when the address is to a subprogram? Can Address_to_Access_Conversions be instantiated with a subprogram? That's what I've been trying to do, but I don't know how to make a generic that takes an access to an arbitrary subprogram type. So, I think I am "stuck" using the for X'address specification. Thanks, REH