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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,f494beedc5085953 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!p25g2000hsf.googlegroups.com!not-for-mail From: george.priv@gmail.com Newsgroups: comp.lang.ada Subject: Re: Obtaining access to protected object Date: Wed, 9 Jul 2008 08:33:20 -0700 (PDT) Organization: http://groups.google.com Message-ID: <59ed2f49-92e7-4d9d-b88e-5fbd28824d91@p25g2000hsf.googlegroups.com> References: <72741a06-d96c-4f53-a80b-3595c513efa1@27g2000hsf.googlegroups.com> NNTP-Posting-Host: 151.196.71.114 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1215617600 20852 127.0.0.1 (9 Jul 2008 15:33:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 9 Jul 2008 15:33:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: p25g2000hsf.googlegroups.com; posting-host=151.196.71.114; posting-account=VnNb3AoAAACTpRtCcTrcjmPX7cs92k1Q User-Agent: G2/1.0 X-HTTP-Via: 1.1 SPARKS X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.15) Gecko/20080623 Firefox/2.0.0.15,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:1049 Date: 2008-07-09T08:33:20-07:00 List-Id: On Jul 8, 4:41 pm, Maciej Sobczak wrote: > Consider 9.4-21/2: > > "Within the declaration or body of a protected unit other than in an > access_definition, the name of the protected unit denotes the current > instance of the unit" > > I understand that this allows me to obtain the access to the current > object (the "this" access) of the protected object. > Let's try: > > protected type P is > procedure Foo; > end P; > > protected body P is > procedure Foo is > Ptr : access P; -- P denotes the type P > begin > Ptr := P'Access; -- here P denotes the "this" instance of > P > end; > end P; > > This is what GNAT has to say about it: ""Access" attribute cannot be > applied to type". > As far as I understand, this is in conflict with the AARM paragraph > mentioned above. > > Am I doing something wrong or is it a compiler bug? > > -- > Maciej Sobczak *www.msobczak.com*www.inspirel.com The instance may not be aliased, and type itself is not enough to determine that at compile time. You can reference the protected type "this" instance though: protected type Xt is procedure Foo; end Xt; procedure Call_Foo (A : in out Xt); protected body Xt is procedure Foo is begin Call_Foo (Xt); end; end Xt;