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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4885c546f6ddc77a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.230 with SMTP id pz6mr527032pbc.3.1340304190003; Thu, 21 Jun 2012 11:43:10 -0700 (PDT) MIME-Version: 1.0 Path: l9ni4119pbj.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Dynamic accessibility Date: Thu, 21 Jun 2012 13:43:06 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1340304188 3209 69.95.181.76 (21 Jun 2012 18:43:08 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 21 Jun 2012 18:43:08 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Date: 2012-06-21T13:43:06-05:00 List-Id: 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.