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!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada Alternatives to Unrestricted_Access Date: Sun, 11 Mar 2018 20:27:05 +0200 Organization: Tidorum Ltd Message-ID: References: <4ab69a18-5766-446c-85c2-14e094199c95@googlegroups.com> <6792fcd7-a25a-417c-b45a-1a17b0168234@googlegroups.com> <5c448ce7-5646-45c5-b221-3d9c884c4d52@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net ArSJqTzZM22IuzPKMRumqwKB/sIQTseM/xb+FwUqBlJKcr/+oD Cancel-Lock: sha1:vbe3r/J6lgXUtSDh9uoKS0Vc0NY= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: reader02.eternal-september.org comp.lang.ada:50931 Date: 2018-03-11T20:27:05+02:00 List-Id: 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 . @ .