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-Thread: a07f3367d7,19b8909eebb73a8e X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!novso.com!news.skynet.be!195.238.0.222.MISMATCH!newsspl501.isp.belgacom.be!tjb!not-for-mail Date: Sat, 30 May 2009 16:16:12 +0200 From: Olivier Scalbert User-Agent: Thunderbird 2.0.0.21 (X11/20090409) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question on Controlled types References: <4a211b98$0$2862$ba620e4c@news.skynet.be> <1m6a6s5xq3hrf.1i7zbi65wq3cd$.dlg@40tude.net> In-Reply-To: <1m6a6s5xq3hrf.1i7zbi65wq3cd$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4a213fd0$0$2847$ba620e4c@news.skynet.be> Organization: -= Belgacom Usenet Service =- NNTP-Posting-Host: ca15990e.news.skynet.be X-Trace: 1243693008 news.skynet.be 2847 80.201.76.217:52253 X-Complaints-To: usenet-abuse@skynet.be Xref: g2news2.google.com comp.lang.ada:6119 Date: 2009-05-30T16:16:12+02:00 List-Id: Dmitry A. Kazakov wrote: > On Sat, 30 May 2009 13:41:41 +0200, Olivier Scalbert wrote: >> Initialize Delay_Line >> Make_Delay_Line >> Adjust Delay_Line >> Finalize Delay_Line >> Finalize Delay_Line >> >> I have two "Finalize(s)" for one "Initialize". > > This is a correct behavior. > >> Should I call Initialize from Adjust ? > > No. > >> How to have only one Initialize/Finalize ? > > You cannot (need not). Here is an interpretation of what happens in your > case: > > 1. When Make_Delay_Line is called it creates local variable D. This is your > call to Initialize. > > 2. Then it returns D. For this the content of D is copied into Delay1 of > the caller and Adjust is done. That is your Adjust. > > 3. Then D is destroyed and Finalize is called. That is your first call to > Finalize. > > 4. When test1 is completed, Delay1 is destroyed and so the second call to > Finalize happens. > > The formula is I + A = F, where I is the number of calls to Initialize, A > is the number of calls to Adjust and F is the number of calls to Finalize. > > Note that the compiler has right to optimize some pairs Adjust/Finalize > away or add new ones. > Thanks Dmtry. Inside the Initialize I will later create a (very) large array. Inside the Finalize I will free this large array. If I want to use only one instance of Delay_Time, how can I reformulate the program to have only one I and one F ? Olivier