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: In mode parameter in an assignment statement Date: Sat, 13 Oct 2018 10:38:01 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <82fdea5d-b9b6-4f1e-a45f-ee0ff9f55946@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 13 Oct 2018 08:38:01 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="7662e1d1b63a32fd60e63a20d09af872"; logging-data="26135"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+534D+VjOSoY4IV7TSw8vYeUfDauze+XE=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 Cancel-Lock: sha1:5vygou/ySih/D8DqqPSLMc+A9RY= In-Reply-To: <82fdea5d-b9b6-4f1e-a45f-ee0ff9f55946@googlegroups.com> Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:54562 Date: 2018-10-13T10:38:01+02:00 List-Id: On 10/13/2018 02:48 AM, Anh Vo wrote: > > I thought it should be rejected during compilation because in mode parameter is not allowed in an assignment statement. But, it was compiled successfully under GNAT obviously. > > What did I miss? Thanks in advance. Others have pointed out that the in-mode parameter, Region, is of an access type. What may not be clear is why this makes a difference. It's important to distinguish the access value (stored in Region) from its designated value (Region.all). The access value is constant within the procedure; any attempt to change it Region := new Mapped_Region_Record; would result in a compiler error. However, the access value is the only thing that is an in-mode parameter and constant within the procedure. The designated value, Region.all, is not constant and may be modified. That is what's happening in the procedure. That Ada access types allow for implicit dereference and can usually be used exactly the same way as the designated value can be confusing if one is not aware that the type is an access type. -- Jeff Carter It's better to be root than to reboot. 119