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,FREEMAIL_FROM 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 06:33:18 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!news-peer.gip.net!news.gsl.net!gip.net!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0902.news.uu.net!not-for-mail Date: Mon, 16 Dec 2002 09:33:15 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.2b) Gecko/20021009 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: controlled initialization References: <3DFD7B15.9050800@mbank.com.ua> In-Reply-To: <3DFD7B15.9050800@mbank.com.ua> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1040049195.294541@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@fixedcost.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1040049196 10229 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:31894 Date: 2002-12-16T09:33:15-05:00 List-Id: Maxim Reznik wrote: > 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". > > But when I compile program with GNAT 3.15p for Linux > it doesn't happen. > > May be it's bug of GNAT? Ooh, ooh, I know, I know! I remember this from a thread a while ago. Init isn't called for objects that are initialized by aggregates. A rationale is that since you are supplying all the fields in the aggregate, you can just do whatever setup the Init proccedure would have done. Of course, this doesn't work if the Init procedure has side effects. In that case, I think the solution is to make the type limited, so that users can't initialize with aggregates at all, and you can call the Init procedure "by hand" in the private code.