comp.lang.ada
 help / color / mirror / Atom feed
From: Jere <jhb.chat@gmail.com>
Subject: Re: Ada Alternatives to Unrestricted_Access
Date: Thu, 8 Mar 2018 16:36:40 -0800 (PST)
Date: 2018-03-08T16:36:40-08:00	[thread overview]
Message-ID: <4ab69a18-5766-446c-85c2-14e094199c95@googlegroups.com> (raw)
In-Reply-To: <p7rt64$s20$1@dont-email.me>

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.  



  reply	other threads:[~2018-03-09  0:36 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-07 20:11 Ada Alternatives to Unrestricted_Access Jere
2018-03-07 20:38 ` Dmitry A. Kazakov
2018-03-07 22:29   ` Jere
2018-03-08  8:27     ` Dmitry A. Kazakov
2018-03-09  0:43       ` Jere
2018-03-09  0:52         ` Jere
2018-03-09  8:28           ` Dmitry A. Kazakov
2018-03-11  0:31             ` Jere
2018-03-08  3:18 ` gautier_niouzes
2018-03-09  0:41   ` Jere
2018-03-08 17:51 ` Jeffrey R. Carter
2018-03-09  0:36   ` Jere [this message]
2018-03-09 16:46     ` Jeffrey R. Carter
2018-03-11  0:38       ` Jere
2018-03-11  9:57         ` Jeffrey R. Carter
2018-03-11 10:44           ` Dmitry A. Kazakov
2018-03-11 14:31           ` Jere
2018-03-11 15:49             ` Jeffrey R. Carter
2018-03-11 17:33               ` Jere
2018-03-11 18:12                 ` Jeffrey R. Carter
2018-03-11 19:53                   ` Jere
2018-03-12 16:28                     ` Jeffrey R. Carter
2018-03-11 18:27                 ` Niklas Holsti
2018-03-11 20:07                   ` Jere
2018-03-12 23:35                     ` Randy Brukardt
2018-03-12 23:30         ` Randy Brukardt
2018-03-13  7:46           ` Niklas Holsti
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox