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,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-05 07:50:21 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!naxos.belnet.be!news.belnet.be!snic.vub.ac.be!not-for-mail From: Didier Pieroux Newsgroups: comp.lang.ada Subject: [HELP] Why is 'Adjust' not called here ??? Date: Tue, 05 Feb 2002 11:48:32 +0100 Organization: Free University of Brussels (ULB) Message-ID: <3C5FB880.6FD36A12@hotmail.com> NNTP-Posting-Host: ontpc2.ulb.ac.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: snic.vub.ac.be 1012906022 11272 164.15.131.81 (5 Feb 2002 10:47:02 GMT) X-Complaints-To: usenet@snic.vub.ac.be NNTP-Posting-Date: 5 Feb 2002 10:47:02 GMT X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.10 i686) X-Accept-Language: French, fr, French/Belgium, fr-BE, en Xref: archiver1.google.com comp.lang.ada:19636 Date: 2002-02-05T10:47:02+00:00 List-Id: Hello, To make it short: why is 'Adjust' not called during initialization by a aggregate ? 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 == a.ads ============================================================= with Ada.Finalization; package A is type Instance is new Ada.Finalization.Controlled with record N: Integer; end record; procedure Initialize(Self: in out Instance); procedure Adjust (Self: in out Instance); procedure Finalize (Self: in out Instance); end A; == a.adb ============================================================= with Ada.Text_Io; use Ada.Text_Io; package body A is procedure Initialize(Self: in out Instance) is begin Put_Line("Init"); end; procedure Adjust(Self: in out Instance) is begin Put_Line("Adjust"); end; procedure Finalize(Self: in out Instance) is begin Put_Line("Finalize"); end; end A; == my_test.adb ======================================================= with Ada.Finalization; with A; procedure My_Test is Item1 : A.Instance := (Ada.Finalization.Controlled with 10); Item2 : A.Instance := Item1; begin null; end My_Test; == Result: =========================================================== ~/Ada/test > gnatmake my_test.adb gnatgcc -c my_test.adb gnatgcc -c a.adb gnatbind -x my_test.ali gnatlink my_test.ali ~/Ada/test > my_test Adjust <-- this corresponds to the Item2 elaboration. Finalize Finalize ~/Ada/test > -- _________________________________________________________________ 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 _________________________________________________________________