comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Dynamic accessibility
Date: Thu, 21 Jun 2012 13:43:06 -0500
Date: 2012-06-21T13:43:06-05:00	[thread overview]
Message-ID: <jrvpvs$349$1@munin.nbi.dk> (raw)
In-Reply-To: d2894d55-cb84-461c-8b82-da32093eda4b@googlegroups.com

<sbelmont700@gmail.com> wrote in message 
news:d2894d55-cb84-461c-8b82-da32093eda4b@googlegroups.com...

...
>   On the other hand, if there is a good reason for doing it, then it would 
> seem appropriate
> that one would need the same ability for access discriminants as well; 
> i.e. carry along
> the dynamic lifetime so that someone could explicitly typecast it and save 
> it somewhere else,
> exactly like an access parameter.

Well, this comes up from time-to-time -- it surely would be better if access 
discriminants had dynamic accessibility. However, the last time the idea was 
brought up, it was determined that dynamic accessibility would not work at 
all for discriminants. I forget the details, sorry, but my recollection was 
that it was impossible to implement.

BTW, there is concern that the dynamic accessibility of Ada 2005 and Ada 
2012 is in fact unimplementable as well. (AdaCore has not yet managed to do 
so.) The main problem is that we can't quite imagine what the alternative 
is, so it might have to be done in a very expensive manner.

Thus is is good that you can avoid dynamic accessibility by avoiding access 
parameters; use "aliased in out" in Ada 2012 instead and you get the *right* 
accessibility. ("in out" acts as local; "aliased in out" acts as if the 
accessibility is the point of the call -- this sounds hardly different, but 
it makes a huge difference in practice, as you cannot return the first but 
you can return the second.)

Note that dynamic accessibility is always a bad idea, in that it provides 
"tripping hazard" -- you might get an exception from a few calls, but not 
others. It's especially bad as calls from unit tests most likely will work 
(they're not nested) while ones in actual programs might (calls in nested 
subprograms are much more common).

I've become convinced that the entire idea of accessibility checks isn't 
worth the headaches (both in language definition and in practice). I 
virtually always use 'Unchecked_Access in my code, so the net effect is that 
I pay overhead for accessibility checks, but they never actually have any 
effect (positive or negative). 'Access will almost always fail on a 
parameter, so it doesn't even make sense to try to use it -- and it's very 
rare to have anything that is not encapsulated (the only time 'Access can be 
used).

                                     Randy.





  reply	other threads:[~2012-06-21 18:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 21:31 Dynamic accessibility sbelmont700
2012-06-21 18:43 ` Randy Brukardt [this message]
2012-06-22  0:43   ` sbelmont700
2012-06-22 20:03     ` Randy Brukardt
2012-06-24 16:51       ` sbelmont700
2012-06-26 22:53         ` Randy Brukardt
replies disabled

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