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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,d23826ff0acb491b X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!news.unit0.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Gem 39 - compiler specific? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <9e0bbbcd-260f-48ed-8043-d6280c633e85@h3g2000yqa.googlegroups.com> <19268dbw82hf4.aii8as09aapk.dlg@40tude.net> <4bff103b-1797-4e2b-9dcf-7466b667c59b@d9g2000prh.googlegroups.com> Date: Thu, 3 Sep 2009 18:38:38 +0200 Message-ID: <1s8kuin5t96vr$.1taw9mluqlplz$.dlg@40tude.net> NNTP-Posting-Date: 03 Sep 2009 18:38:38 CEST NNTP-Posting-Host: 2722a8e4.newsspool2.arcor-online.net X-Trace: DXC=0Xa5MgQZA?X\PS5Xo=M[RVA9EHlD;3YcR4Fo<]lROoRQ^YC2XCjHcbYPE31VF^PL]RDNcfSJ;bb[UIRnRBaCdU X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:8131 Date: 2009-09-03T18:38:38+02:00 List-Id: On Thu, 3 Sep 2009 08:26:50 -0700 (PDT), Adam Beneschan wrote: > On Sep 3, 12:26�am, "Dmitry A. Kazakov" > wrote: >> Skewed address is not a problem here. The problem is that >> System.Address_To_Access_Conversions should take an access type as a >> parameter rather than declare it new. This makes its use quite limited. > > I don't see any limitation, at least where To_Pointer is concerned > (which is what the above code needed to use). If you declare an > instance of this package for any object type T: > > type Convert_T_Access is new System.Address_To_Access_Conversions > (T); > > then an object of type Convert_T_Access.Object_Pointer can be > converted to any access type whose designated type is T. I checked > through the legality rules in 4.6, and I couldn't find a way to > declare an access-to-T type that you couldn't convert an > Object_Pointer to. Thus, if you have any access type > > type Acc_T is access T; [or access all T, or access constant T] > > you can convert an address Addr to an Acc_T by saying: > > Acc_T (Convert_T_Access.To_Pointer (Addr)) But Acc_T is a pool-specific access, while Address_To_Access_Conversions creates a general access type. Here Unchecked_Conversion between access types is required, which AFIAK is not guaranteed to work anyway. In some cases I use: declare X : T; for X'Address use Addr; pragma Import (X); begin ... > There do seem to be some limitations on using To_Address, though; you > can't convert an "access constant T" to an Object_Pointer, and you > can't convert an access-to-T type that is nested inside a subprogram. Yes, accessibility rules is another major nuisance. > So you couldn't use To_Address on those types. Offhand, though, I'd > guess that there is much less need for this than for To_Pointer, so > this may not be a severe enough limitation to require fixing. That happens quite often in generic bodies. An access type comes from a formal parameter, Address_To_Access_Conversions is instantiated within the generics. In many (most?) cases I used considered it, I must resort to the old and ugly Ada programmer's friend .all'Unchecked_Access... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de