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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Ada Alternatives to Unrestricted_Access Date: Sun, 11 Mar 2018 16:49:27 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org 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 Injection-Date: Sun, 11 Mar 2018 15:49:27 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bc3283d1cd656c5294f31a4ebedb5cd7"; logging-data="5674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19u0NTBpU4FxLBO1Mf6XghUAgWBDFXd/s0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: <5c448ce7-5646-45c5-b221-3d9c884c4d52@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:bZ9YiIDsy6GCZt/AVkHFlDnNdsg= Xref: reader02.eternal-september.org comp.lang.ada:50928 Date: 2018-03-11T16:49:27+01:00 List-Id: 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. -- Jeff Carter "Sir Robin the not-quite-so-brave-as-Sir-Lancelot, who had nearly fought the Dragon of Angnor, who nearly stood up to the vicious Chicken of Bristol, and who had personally wet himself at the Battle of Badon Hill." Monty Python & the Holy Grail 68