comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Obtaining access to protected object
Date: Thu, 10 Jul 2008 07:46:53 -0700 (PDT)
Date: 2008-07-10T07:46:53-07:00	[thread overview]
Message-ID: <58cc7c4b-f849-48cd-a65b-d4a345ddc048@2g2000hsn.googlegroups.com> (raw)
In-Reply-To: c78104d1-55f2-42d4-8f50-302ff18da3ed@d1g2000hsg.googlegroups.com

On Jul 9, 7:10 pm, george.p...@gmail.com wrote:
> On Jul 9, 3:27 pm, Adam Beneschan <a...@irvine.com> wrote:
>
> > On Jul 9, 8:33 am, george.p...@gmail.com wrote:
>
> > > The instance may not be aliased, and type itself is not enough to
> > > determine that at compile time.
>
> > Wrong.  The current instance of a protected type is always considered
> > aliased, and 'Access is allowed.  3.10(9/2).
>
> >                              -- Adam
>
> I may be wrong,

You're definitely wrong about the rules.  If there's a possibility
that the rules can allow a programmer to write a legal program that
creates a dangling reference (without involving certain dangerous
features), then the ARG needs to hear about it.  But I don't think
that's the case here.  The biggest problem, as far as I know, with
allowing something to access an unaliased object, is that the compiler
may not realize that something could point to it, and therefore could
optimize certain calculations so that the object doesn't necessarily
hold the right value when expected, which will then be a problem if
the program does a dereference of the access.  However, none of this
reasoning applies to protected types, or task types.

In fact, there would probably be no accessing problem at all if *all*
protected and task objects were considered aliased, even without an
explicit "aliased" keyword.  See AARM 3.10(9.l/2) [that's "nine" "dot"
"the lower-case letter L"]; the ARG actually considered doing this for
all by-reference types (which would include task and protected types,
as well as all tagged types and all limited record types).  They
decided not to do so because of some problems involving private parts.


> but it seems that Aliaseness is guaranteed only within
> the protected body. So taking pointer and spilling it outside of the
> scope (even if allowed) is bad idea IMHO.

See above; there's no danger in letting such pointers outside, even if
the object is not explicitly declared as "aliased".  Were it not for
some problems involving privacy breakage, the ARG saw no danger in
simply decreeing that all protected types, etc., are automatically
aliased.


> If used inside the
> protected body then what's advantage of using pointer vs. referring
> directly?

Because you could have an object of an access-to-protected type that
could, in some instances, be set to the same protected type, or could
be set to point to some other protected type.  Of course there's
little point in setting up a pointer that always refers to the same
object; the idea is that you could modify it to point to something
else.

                                 -- Adam






      reply	other threads:[~2008-07-10 14:46 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
2008-07-09 19:27   ` Adam Beneschan
2008-07-10  2:10     ` george.priv
2008-07-10 14:46       ` Adam Beneschan [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox