comp.lang.ada
 help / color / mirror / Atom feed
From: "Beard, Frank Randolph CIV" <frank.beard@navy.mil>
To: "Alex Xela" <xela2@free.fr>, <comp.lang.ada@ada-france.org>
Subject: RE: Question on controlled types
Date: Wed, 1 Oct 2003 16:03:37 -0400
Date: 2003-10-01T16:03:37-04:00	[thread overview]
Message-ID: <mailman.22.1065038676.25614.comp.lang.ada@ada-france.org> (raw)

Well, not exactly nothing.  It initializes J.  In this case, A gets set
to 0 (zero).  The version that causes PROGRAM_ERROR happens because the
Initialize method is called before it has been elaborated.

IIRC, basically the differences are:

--+ Initialize without calling the Initialize procedure.
J : Instrum.Instrum_Type := (Ada.Finalization.Controlled with A=>0);

--+ Call the Initialize procedure.
J : Instrum.Instrum_Type;

--+ Call Finalize for J, copy X, then call Adjust for J.
J := X;

Frank


-----Original Message-----
From: Alex Xela [mailto:xela2@free.fr]

On the following code, what should happen during J variable elaboration?

 - Nothing

 - A call to Adjust.

I tried to find the answer in RM95 but in vain.

My tests on several compilers (and my feeling) were suggesting  : nothing!





--CODE :
begin ----------------------------------------------------------------------
------------------

with Ada.Finalization;

package Instrum is

    type Instrum_Type is new Ada.Finalization.Controlled with

    record

        A : Integer;

    end record;

    procedure Finalize  (O : in out Instrum_Type);

    procedure Adjust  (O : in out Instrum_Type);

    procedure Initialize  (O : in out Instrum_Type);

    J : Instrum.Instrum_Type := ( Ada.Finalization.Controlled with
A=>0);--nothing?

    --J : Instrum.Instrum_Type; --raised PROGRAM_ERROR : access before
elaboration

end Instrum;

--CODE :
end ------------------------------------------------------------------------
------------------



             reply	other threads:[~2003-10-01 20:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-01 20:03 Beard, Frank Randolph CIV [this message]
2003-10-02 18:45 ` Question on controlled types Robert I. Eachus
  -- strict thread matches above, loose matches on Subject: below --
2009-05-30 11:41 Question on Controlled types Olivier Scalbert
2009-05-30 13:27 ` Dmitry A. Kazakov
2009-05-30 14:16   ` Olivier Scalbert
2009-05-30 14:48     ` Olivier Scalbert
2009-05-30 15:20       ` Robert A Duff
2009-05-30 15:40         ` Olivier Scalbert
2009-05-30 18:37           ` Robert A Duff
2009-06-04 12:32   ` Hibou57 (Yannick Duchêne)
2009-06-04 14:04     ` Dmitry A. Kazakov
2009-06-04 14:34       ` Hibou57 (Yannick Duchêne)
2009-06-04 15:03         ` Dmitry A. Kazakov
2009-06-04 15:13           ` Hibou57 (Yannick Duchêne)
2009-06-06  1:31       ` Randy Brukardt
2009-05-30 13:30 ` christoph.grein
2003-10-02  8:05 Question on controlled types christoph.grein
2003-10-01 19:06 Alex Xela
2003-10-01 23:07 ` Matthew Heaney
2003-10-02  7:09   ` Alex Xela
replies disabled

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