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,faeb0c2550699cee X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-16 15:31:20 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: mheaney@on2.com (Matthew Heaney) Newsgroups: comp.lang.ada Subject: Re: controlled initialization Date: 16 Dec 2002 15:31:20 -0800 Organization: http://groups.google.com/ Message-ID: <1ec946d1.0212161531.31a43505@posting.google.com> References: <3DFD7B15.9050800@mbank.com.ua> NNTP-Posting-Host: 66.162.65.162 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1040081480 22994 127.0.0.1 (16 Dec 2002 23:31:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Dec 2002 23:31:20 GMT Xref: archiver1.google.com comp.lang.ada:31926 Date: 2002-12-16T23:31:20+00:00 List-Id: Maxim Reznik 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.