comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada Alternatives to Unrestricted_Access
Date: Sun, 11 Mar 2018 20:27:05 +0200
Date: 2018-03-11T20:27:05+02:00	[thread overview]
Message-ID: <fglanqF7chkU1@mid.individual.net> (raw)
In-Reply-To: <a185d3c8-63cf-4c38-9546-55a64387476f@googlegroups.com>

On 18-03-11 19:33 , Jere wrote:
> On Sunday, March 11, 2018 at 11:49:28 AM UTC-4, Jeffrey R. Carter wrote:
>> On 03/11/2018 03:31 PM, Jere wrote:
>>>>
>>> It's iterator related.  In order to iterate through a container in all
>>> contexts, the Default_Iterator function needs a parameter of mode "in".
>>> In order to leverage the anti tamper functionality, the iterator needs
>>> a non constant access to the container to be supplied when building
>>> the iterator inside the Default_Iterator function (so it can modify
>>> the tamper state of the container).  The GNAT body for the Vectors
>>> package has an example (I think it is a-convec.adb, just search for
>>> "function iterate" and look for the one that returns an iterator).
>>
>> I doubt the intention of user-defined iteration was to require people to bypass
>> the language checks, so I conclude that it's intended for the container
>> parameter of the Default_Iterator function to have mode "in out". The definition
>> of Default_Iterator doesn't restrict the parameter mode of the container
>> parameter in any way, so "in out" should be accepted.
>>
>> Presumably the Iterator functions for the standard containers have mode "in" for
>> the containers because their bodies don't need to be portable and can use
>> compiler-specific tricks, similar to the Generator parameter of the
>> random-number functions from an earlier version of the language.
>>
>> Or else user-defined iteration seems broken.
>
> The problem I run into with this provided code base, is that it
> often iterates over a constant view of the container.

One way to modify the semantic state of an object, through a constant 
view of the object, is to provide the object with a component that is an 
access to another object that contains the state you want to modify.

For example, to implement the tamper check, the container could have an 
"access Boolean" component where the Boolean is the flag that enables 
the tamper checks (or perhaps it should be a Natural, to handle nested 
iterations).

Or you could use the "Rosen trick", with a container component that is 
an access (variable view) to the container itself.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .


  parent reply	other threads:[~2018-03-11 18:27 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
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 [this message]
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