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 10:57: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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 11 Mar 2018 09:57:45 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="bc3283d1cd656c5294f31a4ebedb5cd7"; logging-data="27878"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TzyFXbj0Uzrl3jRUJ1nfiHhREqMe8JKw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-Reply-To: <6792fcd7-a25a-417c-b45a-1a17b0168234@googlegroups.com> Content-Language: en-US Cancel-Lock: sha1:XzuOZB/4OnQia1MOs+Bsut4lCWo= Xref: reader02.eternal-september.org comp.lang.ada:50924 Date: 2018-03-11T10:57:45+01:00 List-Id: On 03/11/2018 01:38 AM, Jere wrote: > On Friday, March 9, 2018 at 11:46:03 AM UTC-5, Jeffrey R. Carter wrote: >> >> OK, that's what I missed. I guess you could unchecked convert from >> access-constant to access-all. >> > My only concern with this is does the Ada language allow it portably? I > know it works in GNAT, but what I couldn't find is if the RM allowed > for a constant variable to have a different internal representation than > a non constant version of the variable. If that were the case, then I > would be worried that doing an unchecked_conversion (or an > Address_To_Access_Conversion) could provide an erroneous result. Since your type is tagged, parameters are passed by reference, so your "in" parameter is a constant view of the variable. As such, it has the same representation as the full (non-constant) view of variable. Nothing in the ARM puts any requirements on the representation of access types, so it's possible that access-constant and access-all could have different representations. The distinction between the two would seem to be a compile-time concept that would not be explicitly represented at run time. Given the general rule that compiler writers don't make things more difficult for themselves than they need to, it seems unlikely that the access values would have different representations, and unchecked converting between them should be OK. Input from compiler writers would be more valuable than my uneducated guessing, though. Since tagged parameters are always aliased, address-to-access conversion should always be correct. Why do you need this function? -- 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