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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1e12d8e0da8e9a65 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-14 12:05:06 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cis.ohio-state.edu!news.maxwell.syr.edu!news.he.net!cyclone-sf.pbi.net!151.164.30.35!cyclone.swbell.net!bos-service1.ext.raytheon.com!cambridge1-snf1.gtei.net!news.gtei.net!inmet!not-for-mail From: Tucker Taft Newsgroups: comp.lang.ada Subject: Re: [HELP] Why is 'Adjust' not called here ??? Date: Thu, 14 Feb 2002 15:05:05 -0500 Organization: AverCom Corp, a Titan company Message-ID: <3C6C1871.AF871003@avercom.net> References: <3C5FB880.6FD36A12@hotmail.com> NNTP-Posting-Host: 192.168.24.34 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: inmet2.burl.averstar.com 1013717105 12830 192.168.24.34 (14 Feb 2002 20:05:05 GMT) X-Complaints-To: usenet@inmet2.burl.averstar.com NNTP-Posting-Date: 14 Feb 2002 20:05:05 GMT X-Mailer: Mozilla 4.79 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:20022 Date: 2002-02-14T20:05:05+00:00 List-Id: Didier Pieroux wrote: > > Hello, > > To make it short: why is 'Adjust' not called during initialization by a > aggregate ? We debated this during the Ada 95 design process. We decided that Adjust is called after *copying* an existing value, Initialize is called to create a (new) value by default initialization, and an aggregate may be used to create a new value exactly as you want it to end up. Calling Adjust after evaluating the aggregate could be confusing. Of course, we could have done it otherwise, and required that when you write an aggregate, you keep in mind that Adjust is going to be applied to it. The second issue is whether an aggregate used to initialize an object should be built in a temporary and then copied into the object, or built "in place." There are many advantages to requiring that the aggregate be built "in place." As mentioned elsewhere, it allows you to initialize constants *before* the Adjust and Finalize procedures have been elaborated. Secondly, it avoids the need to allocate space for the temp, copy the temp into the declared object, adjust the declared object, finalize the temp, and deallocate the temp. Of course allocation/deallocation might be cheap due to being on the stack, but the copy, adjust, and finalize could be expensive. The original Ada 95 RM didn't require that you build the aggregate in place, but a subsequent "Ada Interpretation" (AI-83) has made this an implementation requirement, to allow portable programs to declare and initialize constants with aggregates. If you want to read AI-83, go to: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00083.TXT?rev=1.16 > > I give an example below illustrating my question. 'A.Instance' is a > controlled type with Initialize, Adjust and Finalize redefined to print > their name. > > I thought that the elaboration of > > Item1 : A.Instance := (Ada.Finalization.Controlled with 10); > > would call the 'A.Adjust' procedure... It is not the case. However, > 'A.Adjust' is called as expected after the elaboration of > > Item2 : A.Instance := Item1; > > I check that behavior with both the Gnat and Aonix compiler. So, I am > clearly missing something here, and I can't find the answer in my books > (Barnes, Cohen, Ben-Ari and the RM) > > Also, could someone > - Explain me the rational for not calling 'Adjust' in the first case ? > - Give me the key reference(s) in the RM from which this behavior can be > deduced ? > > Thank in advance for the light ! > Didier >... > _________________________________________________________________ > > Didier Pieroux > Theoretical Nonlinear Optics, CP 231 > Physics Department, Universite Libre de Bruxelles > Bvd du Triomphe, B-1050 Brussels, Belgium > > Phone: ++ 32 2 650 5903, Fax: ++ 32 2 650 5824 > dpieroux@hotmail.com > _________________________________________________________________ -- -Tucker Taft stt@avercom.net http://www.avercom.net Chief Technology Officer, AverCom Corporation (A Titan Company) Bedford, MA USA (AverCom was formerly the Commercial Division of AverStar: http://www.averstar.com/~stt)