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!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: assignment aggregates in controlled types Date: Sun, 23 Feb 2020 12:07:58 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <7c74a973-e278-427c-bbda-f4c1ebf8fdef@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sun, 23 Feb 2020 11:07:58 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="a4b62d63aa476caa59ca367f414fb3c4"; logging-data="27720"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/oO5FyAanRSahXd0XFQemw1t/3BQJpNWw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 Cancel-Lock: sha1:BGYQkeLCYStznpDlWCXOj3CQQ74= In-Reply-To: <7c74a973-e278-427c-bbda-f4c1ebf8fdef@googlegroups.com> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:58128 Date: 2020-02-23T12:07:58+01:00 List-Id: On 2/23/20 2:23 AM, sbelmont700@gmail.com wrote: > > Does anyone know what, if anything, the language say about the use of assignment aggregates during adjust/finalize procedures? If you do something like this: > > procedure Finalize (Object : in out T) is > begin > Object := (x => 0); > end; > > does not that create a temporary object on the RHS that is assigned (and adjusted) into the LHS, and then the RHS itself finalized by calling Finalize, and then it's finalization procedures all the way down? This is perfectly safe, because it won't compile. You need to write Object := (Controlled with X => 0); The canonical behavior is to create a temporary, though it may be optimized away, and I have not heard of any exception for controlled types, so I would suggest avoiding such a construct. Have you tried experimenting to see what happens? -- Jeff Carter "My legs are gray, my ears are gnarled, my eyes are old and bent." Monty Python's Life of Brian 81