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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: A few questions Date: Tue, 17 Nov 2015 15:33:39 -0600 Organization: JSA Research & Innovation Message-ID: References: <5007b311-5d2e-448c-b8c8-fc2e2d88ea5e@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1447796021 11118 24.196.82.226 (17 Nov 2015 21:33:41 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 17 Nov 2015 21:33:41 +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 Xref: news.eternal-september.org comp.lang.ada:28425 Date: 2015-11-17T15:33:39-06:00 List-Id: "Simon Wright" wrote in message news:ly1tbpipgd.fsf@pushface.org... > "Randy Brukardt" writes: > >> Since 'Unrestricted_Access is GNAT junk, it's doesn't have any value >> for a sample implementation (if you really need 'Unrestricted_Access, >> then the interface can't be implemented in Ada, and that would be a >> major problem.) So far as I know, you might need to use >> 'Unchecked_Access, but that's necessary anytime one needs to get a >> pointer to save the evaluated version of something. > > I can't of course speak for AdaCore, but I think that the problem is > to do with obtaining a writable view of an in parameter; for example, in > the Bounded Hashed Map (GCC 5) there is > > function Iterate > (Container : Map) return > Map_Iterator_Interfaces.Forward_Iterator'Class > is > B : Natural renames Container'Unrestricted_Access.all.Busy; > begin > return It : constant Iterator := > (Limited_Controlled with > Container => Container'Unrestricted_Access) > do > B := B + 1; > end return; > end Iterate; > > I dare say something could be done with 'Address and Address To Access > Conversions. As Brad noted, you have to use the Rosen technique here. Not hacks like 'Unrestricted_Access. (The Rosen technique is not a "trick", it's an intended part of the language in Ada 2012. I admit it originally was accidental, but it's too widely used to eliminate.) Randy.