comp.lang.ada
 help / color / mirror / Atom feed
From: Olivier Scalbert <olivier.scalbert@algosyn.com>
Subject: Re: Question on Controlled types
Date: Sat, 30 May 2009 16:16:12 +0200
Date: 2009-05-30T16:16:12+02:00	[thread overview]
Message-ID: <4a213fd0$0$2847$ba620e4c@news.skynet.be> (raw)
In-Reply-To: <1m6a6s5xq3hrf.1i7zbi65wq3cd$.dlg@40tude.net>

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








  reply	other threads:[~2009-05-30 14:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-30 11:41 Question on Controlled types Olivier Scalbert
2009-05-30 13:27 ` Dmitry A. Kazakov
2009-05-30 14:16   ` Olivier Scalbert [this message]
2009-05-30 14:48     ` Olivier Scalbert
2009-05-30 15:20       ` Robert A Duff
2009-05-30 15:40         ` Olivier Scalbert
2009-05-30 18:37           ` Robert A Duff
2009-06-04 12:32   ` Hibou57 (Yannick Duchêne)
2009-06-04 14:04     ` Dmitry A. Kazakov
2009-06-04 14:34       ` Hibou57 (Yannick Duchêne)
2009-06-04 15:03         ` Dmitry A. Kazakov
2009-06-04 15:13           ` Hibou57 (Yannick Duchêne)
2009-06-06  1:31       ` Randy Brukardt
2009-05-30 13:30 ` christoph.grein
  -- strict thread matches above, loose matches on Subject: below --
2003-10-02  8:05 Question on controlled types christoph.grein
2003-10-01 20:03 Beard, Frank Randolph CIV
2003-10-02 18:45 ` Robert I. Eachus
2003-10-01 19:06 Alex Xela
2003-10-01 23:07 ` Matthew Heaney
2003-10-02  7:09   ` Alex Xela
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox