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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:b915:: with SMTP id w21-v6mr579849ite.14.1520555801183; Thu, 08 Mar 2018 16:36:41 -0800 (PST) X-Received: by 10.157.68.9 with SMTP id u9mr1448902ote.5.1520555800669; Thu, 08 Mar 2018 16:36:40 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!r195no122229itc.0!news-out.google.com!a2-v6ni212ite.0!nntp.google.com!e10-v6no121486itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 8 Mar 2018 16:36:40 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.218.250; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.218.250 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <4ab69a18-5766-446c-85c2-14e094199c95@googlegroups.com> Subject: Re: Ada Alternatives to Unrestricted_Access From: Jere Injection-Date: Fri, 09 Mar 2018 00:36:41 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:50900 Date: 2018-03-08T16:36:40-08:00 List-Id: On Thursday, March 8, 2018 at 12:51:02 PM UTC-5, Jeffrey R. Carter wrote: > On 03/07/2018 09:11 PM, Jere wrote: > > > > function Iterate > > (C : in Container) > > return Iterator_Interfaces.Forward_Iterator'Class; > > > > and the generic formal for Container > > > > type Container is tagged private; > > Since Container is tagged, the parameter C should be aliased [ARM 3.10(9)], so > you should be able to use 'Unchecked_Access. Or am I missing something? > > -- > Jeff Carter > "I've got to stay here, but there's no reason > why you folks shouldn't go out into the lobby > until this thing blows over." > Horse Feathers > 50 It generates the error "access-to-variable designates constant" because the function takes a parameter of mode "in" while the iterator needs a non-constant access to the variable. I can't change the mode of the function for other reasons. I checked the definition of Unchecked_Access (13.10) and it only addresses the accessibility restrictions on taking 'Access: 13.10 [3] All rules and semantics that apply to X'Access (see 3.10.2) apply also to X'Unchecked_Access, except that, for the purposes of accessibility rules and checks, it is as if X were declared immediately within a library package. Keep in mind I am not having trouble getting past the Accessibility level, I am having trouble getting past the "const"ed-ness of the parameter since it needs to be of mode "in" to work with user defined iteration. If you look at the vector implementation in GNAT, you'll see that in the iterate function they have to use Unrestricted_Access for the same reason. I was just hoping for a more ada portable method.