From: george.priv@gmail.com
Subject: Re: Obtaining access to protected object
Date: Wed, 9 Jul 2008 08:33:20 -0700 (PDT)
Date: 2008-07-09T08:33:20-07:00 [thread overview]
Message-ID: <59ed2f49-92e7-4d9d-b88e-5fbd28824d91@p25g2000hsf.googlegroups.com> (raw)
In-Reply-To: 72741a06-d96c-4f53-a80b-3595c513efa1@27g2000hsf.googlegroups.com
On Jul 8, 4:41 pm, Maciej Sobczak <see.my.homep...@gmail.com> 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;
next prev parent reply other threads:[~2008-07-09 15:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-08 20:41 Obtaining access to protected object Maciej Sobczak
2008-07-09 15:03 ` Adam Beneschan
2008-07-09 21:21 ` Maciej Sobczak
2008-07-09 21:57 ` Adam Beneschan
2008-07-09 22:01 ` Georg Bauhaus
2008-07-10 0:39 ` Randy Brukardt
2008-07-09 15:33 ` george.priv [this message]
2008-07-09 19:27 ` Adam Beneschan
2008-07-10 2:10 ` george.priv
2008-07-10 14:46 ` Adam Beneschan
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox