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.1 required=5.0 tests=BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border2.nntp.ams3.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news2.euro.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!news.stack.nl!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Jacob Sparre Andersen news" Newsgroups: comp.lang.ada Subject: Re: Generic access type convention and aliasing Date: Tue, 7 May 2013 16:03:17 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <5a96b4f0-15d3-4fe2-9e9c-000f59b9c864@googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: loke.gir.dk 1367960598 23015 69.95.181.76 (7 May 2013 21:03:18 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 7 May 2013 21:03:18 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-Original-Bytes: 3934 Xref: number.nntp.dca.giganews.com comp.lang.ada:181492 Date: 2013-05-07T16:03:17-05:00 List-Id: "Yannick Duchêne (Hibou57)" wrote in message news:op.wwp94yh5ule2fv@cardamome... ... > Access disciminants are uncopiable. > >If so, that's *very easily defeated*: The issue isn't really whether they can be copied, but rather whether their lifetime can be extended beyond that of the enclosing object. And the answer to this latter question is no. (This allows the enclosing object to include tracking for when the access exists, as in the containers with their tampering checks.) So while you can copy them into a dynamic accessibility context, this doesn't change their lifetime. So your program doesn't work at runtime. This can't be a purely static check simply because of the existence of access parameters and stand-alone access objects (both of which have dynamic rather than static accessibility checks). > procedure Foo is ... > S : Storages.Instance_Type := Storages.Create; > A1 : Pool_Specific_Access := S.Element; -- Illegal. because it fails a static accessibility check. > A2 : access Storages.Element_Type := S.Element; -- However still > legal. I'm not certain about this (SAOAATs require the accessibility lifetime to be at least as long as the object itself, and this isn't). But let's assume this is legal for the sake of argument. > A3 : General_Access := S.Element; -- And the same. Yes, of course this is legal, but it also includes a dynamic accessibility check which will fail for this example. (S.Element is much shorter lives than type General_Access). So it will raise Program_Error. You will not have accomplished copying with this code. >Far from what limited access type would be. Not really, because we have to allow some copying of limited access values or you wouldn't be able to use them at all. At least for initialization (you need to be able to initialize one limited access value with the result of a function returning such a thing). You also may want to pass the value into a subprogram for further processing (which is safe, as the subprogram has to return before the access is destroyed). In cases like these, "limited" is too much. Moreover, the use of access parameters and SAOAATs should be avoided unless you really need dynamic accessibility. It's just one of the many reasons that these things are dangerous and probably never should have been added to Ada in the first place. If you don't use the dangerous constructs (say by using AdaControl to flag them), you won't have the problem you illustrate here. Randy.