comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: assignment aggregates in controlled types
Date: Sun, 23 Feb 2020 12:07:58 +0100
Date: 2020-02-23T12:07:58+01:00	[thread overview]
Message-ID: <r2tmee$r28$1@dont-email.me> (raw)
In-Reply-To: <7c74a973-e278-427c-bbda-f4c1ebf8fdef@googlegroups.com>

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

  reply	other threads:[~2020-02-23 11:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-23  1:23 assignment aggregates in controlled types sbelmont700
2020-02-23 11:07 ` Jeffrey R. Carter [this message]
2020-02-24 23:13 ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox