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: Mon, 12 Mar 2018 17:28:03 +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: Mon, 12 Mar 2018 16:28:03 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="75f1dff931eb2a44ade55a987e387d04"; logging-data="23098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18RpVNCc63JgGykkJcubWlW44U84zLMC0I=" 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:Z6USnfWtxMKKKnzZ6Tzy95oAhxo= Xref: reader02.eternal-september.org comp.lang.ada:50938 Date: 2018-03-12T17:28:03+01:00 List-Id: On 03/11/2018 08:53 PM, Jere wrote: > > procedure Debug_Print(C : Container) is > begin > for E of C loop > Ada.Text_IO.Put_Line(Element'Image(E)); > end loop; > end Debug_Print; > > procedure Nefarious(C : in out Container) is > begin > for E of C loop > if E = Some_Value then > > C.Delete(E); -- tamper check! > end loop; > end Nefarious; If you can't do both with standard, checked programming, then user-defined iteration is broken. > It's all pre-existing code. I don't want to add anything. The > iteration was already there. The owner asked to see if I could > get rid of some GNAT specific extensions easily. > One was the use of Unrestricted_Access, which led me to the original > question. They didn't want a major overhaul of the code. Address-to-access conversions should be correct and portable, but 'Unrestricted_Access is probably clearer. -- Jeff Carter "We'll make Rock Ridge think it's a chicken that got caught in a tractor's nuts!" Blazing Saddles 87