From: mheaney@on2.com (Matthew Heaney)
Subject: Re: controlled initialization
Date: 16 Dec 2002 15:31:20 -0800
Date: 2002-12-16T23:31:20+00:00 [thread overview]
Message-ID: <1ec946d1.0212161531.31a43505@posting.google.com> (raw)
In-Reply-To: 3DFD7B15.9050800@mbank.com.ua
Maxim Reznik <max1@mbank.com.ua> wrote in message news:<3DFD7B15.9050800@mbank.com.ua>...
>
> I expected statement
> return Statement'(Ada.Finalization.Controlled with C => 0);
> created object of type Statement,
> then Initialyze procedure would be called for it and
> Put_Line printed "Init".
>
> May be it's bug of GNAT?
No, there is no bug.
> with Ada.Finalization;
> package Tests is
>
> type Statement is new Ada.Finalization.Controlled with record
> C : Integer;
> end record;
>
> procedure Initialize (Item : in out Statement);
>
> subtype Class is Ada.Finalization.Controlled'Class;
>
> function Create_Statement return Class;
>
> end Tests;
In general, you should hide the fact of derivation from Controlled in
the private part of the spec, like this:
package Tests is
type Statement_Type is private;
...
private
type Statement_Type is new Controlled with record
C : Integer;
end record;
procedure Initialize (Statement : in out Statement_Type);
...
end Tests;
Here, the partial view of the type can be tagged or non-tagged. In my
example above, I have chosen not to make the partial view non-tagged.
next prev parent reply other threads:[~2002-12-16 23:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-16 7:04 controlled initialization Maxim Reznik
2002-12-16 14:33 ` Hyman Rosen
2002-12-16 15:06 ` Robert A Duff
2002-12-16 23:26 ` Matthew Heaney
2002-12-17 1:50 ` Hyman Rosen
2002-12-17 2:00 ` Bill Findlay
2002-12-17 7:55 ` Simon Wright
2002-12-17 6:59 ` Maxim Reznik
2002-12-16 23:31 ` Stephen Leake
2002-12-16 23:31 ` Matthew Heaney [this message]
-- strict thread matches above, loose matches on Subject: below --
2002-12-17 6:20 Grein, Christoph
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox