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 19:12:45 +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 18:12:46 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bc3283d1cd656c5294f31a4ebedb5cd7"; logging-data="10442"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jnQ3ajhnyj7QUO63WMu2nmy3K3At6XOw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:DGzsDMfp02jZmiWqqfv1DvmCxU8= Xref: reader02.eternal-september.org comp.lang.ada:50930 Date: 2018-03-11T19:12:45+01:00 List-Id: On 03/11/2018 06:33 PM, Jere wrote: > > The problem I run into with this provided code base, is that it > often iterates over a constant view of the container. In those cases, > Default_Iterator cannot have a mode of "in out" as you just get the error > > "variable container expected" I can't say I've ever done that. > It's kind of an odd place to be. You want the tamper checks to ensure > container safety/correctness, which potentially requires > Default_Iterator to have mode "in out" but you also don't want to > restrict the Container to only be used in mutable situations. If > you want to use a container in non mutable situations, you need > Default_Iterator to have mode "in". Without tamper checks, everything > can be mode "in" and happy. So you want to bypass one kind of check in order to have another? Is it possible to tamper with a constant container? I presume this code was written for an earlier version of the language, and now you want to bolt on this neat new feature of Ada 12. It seems its design and implementation are not compatible with user-defined iteration. It appears there are 2 clean solutions: 1. Do nothing. You don't need this form of iteration. The existing ways of iterating over the container work fine. 2. Revisit the design and modify the code so it's compatible with user-defined iteration. Trying to use solution 1.5 is going to be messy. -- 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