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,68536605ede13a20 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.73.229 with SMTP id o5mr9417679pbv.7.1324601765056; Thu, 22 Dec 2011 16:56:05 -0800 (PST) MIME-Version: 1.0 Path: lh20ni53527pbb.0!nntp.google.com!news2.google.com!goblin1!goblin.stu.neva.ru!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: GNAT - return by anonymous access Date: Thu, 22 Dec 2011 18:56:01 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <784c67eb-a542-41b0-b23d-fca1234e56b2@n10g2000vbg.googlegroups.com> <95f3b0fc-af24-4ace-afc9-227e8893ea99@n6g2000vbg.googlegroups.com> <91845790-2447-4b2c-a6b5-1a52557c8c17@d10g2000vbk.googlegroups.com> <4f78ef9f-ca8d-43ef-ab71-0f775fbeebd9@z19g2000vbe.googlegroups.com> <6e5ee357-7409-4974-917c-d7236c782d31@h11g2000yqd.googlegroups.com> <8a7d4dc1-69e5-479f-84a3-5c9c7bdd9aae@j10g2000vbe.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1324601763 1961 69.95.181.76 (23 Dec 2011 00:56:03 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 23 Dec 2011 00:56:03 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2011-12-22T18:56:01-06:00 List-Id: "Simon Belmont" wrote in message news:8a7d4dc1-69e5-479f-84a3-5c9c7bdd9aae@j10g2000vbe.googlegroups.com... On Dec 22, 2:11 am, Adam Beneschan wrote: >> I think this could be solved by declaring a private type (limited >> private, if you prefer) to represent an "access" or "handle" or >> "reference" to test_type. >That's essentially the path I was taking, but it's doesn't scale well >(at all, really). You essentially have to remake every primitive >operation of the original type for the new faux-access to forward the >calls so that anything useful could be done. You could use an Ada 2012 accessor (see 4.1.5 in the draft Ada 2012 RM, or AI05-0139-2). It seems that was what you were trying to do (since those depend on an access discriminant) -- but the key is, don't, under *ANY* circumstances, use an allocator for such a type. Initializing the discriminant with an existing object is fine. That's what you'd have to do in Ada 95, so I don't really understand why you suddenly changed to using an allocator in your Ada 2005 code. The Ada 95 facility didn't give you any real protection against modification, so I don't quite see what you think was lost. But, anyway, use the accessor facility: it does give the right lifetime protections. If you want more detail, I'll be happy to work up an example (but I'll be away over the holidays, so not until next week). Randy.