From: Didier Pieroux <dpieroux@pi.be>
Subject: [HELP] Why is 'Adjust' not called here ???
Date: Tue, 05 Feb 2002 11:48:32 +0100
Date: 2002-02-05T10:47:02+00:00 [thread overview]
Message-ID: <3C5FB880.6FD36A12@hotmail.com> (raw)
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
_________________________________________________________________
next reply other threads:[~2002-02-05 10:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-02-05 10:48 Didier Pieroux [this message]
2002-02-05 16:03 ` [HELP] Why is 'Adjust' not called here ??? Pat Rogers
2002-02-05 16:16 ` Stephen Leake
2002-02-05 17:07 ` Pat Rogers
2002-02-06 10:01 ` [Thanks] " Didier Pieroux
2002-02-14 20:05 ` [HELP] " Tucker Taft
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox