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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news4.google.com!feeder.news-service.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!195.14.215.230.MISMATCH!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Question on Controlled types Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4a211b98$0$2862$ba620e4c@news.skynet.be> Date: Sat, 30 May 2009 15:27:52 +0200 Message-ID: <1m6a6s5xq3hrf.1i7zbi65wq3cd$.dlg@40tude.net> NNTP-Posting-Date: 30 May 2009 15:27:52 CEST NNTP-Posting-Host: 5cf1a8d9.newsspool4.arcor-online.net X-Trace: DXC=a8CA`H?Ck[0^8FBo0_81f>4IUKijk60g0o\b=4MK`8 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6117 Date: 2009-05-30T15:27:52+02:00 List-Id: On Sat, 30 May 2009 13:41:41 +0200, Olivier Scalbert wrote: > I am learning controlled types features and I do not understand the > following thing. [...] > 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. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de