comp.lang.ada
 help / color / mirror / Atom feed
From: Dmitry A. Kazakov <mailbox@dmitry-kazakov.de>
Subject: Re: Limited_Controlled types as 'out' arguments
Date: Thu, 31 Jul 2003 12:26:56 +0200
Date: 2003-07-31T12:26:56+02:00	[thread overview]
Message-ID: <93nhiv8khhibv15shv21g2t3o179gf69kl@4ax.com> (raw)
In-Reply-To: slrnbifo7o.o6.lutz@taranis.iks-jena.de

On Wed, 30 Jul 2003 15:15:09 +0000 (UTC), Lutz Donnerhacke
<lutz@iks-jena.de> wrote:

>* Dmitry A Kazakov wrote:
>> On Wed, 30 Jul 2003 14:25:46 +0000 (UTC), Lutz Donnerhacke
>>>* Dmitry A Kazakov wrote:
>>>> On Wed, 30 Jul 2003 12:32:17 +0000 (UTC), Lutz Donnerhacke
>>>>>In my implementation, the type Test contains an array_access, I have to
>>>>>deallocate, before assigning a new value. I can not deallocate this access
>>>>>variable, because the procedure Free (unchecked_deallocate) requires an
>>>>>'in out' Parameter. But I only have an 'out' paramter. So I can't read it,
>>>>>before the first write.
>>>>
>>>> You can in Ada 95.
>>>
>>>Oops. Why? This is a clear data flow error, which should be avoided.
>> 
>> It is an interesting question. What could be alternatives
>> 
>> 1. to leave "out" parameters uninitialized. This is bad.
>
>This is the most common implementation on most types. (most = unless you
>define an Initialize procedure, default component data, or provide
>initialization data)

No they all are initialized, but probably with a garbage. (:-))

A really uninialized object is *(cast *) malloc (). Fortunately, we
have no this evil in Ada.

>> 2. to disallow reading from them, but then how to get discriminants?
>
>Discriminants of 'out' types have mode 'in'. Always.

Not always:

type A (I : Integer := 10) is null record;   
procedure Foo (X : out A) is
begin
   X := (I => 5); -- Change the discriminant
end Foo;

>3) Finalize the current data of the 'limited out' parameter.
>   Adjust the assigned data of the 'unlimited out' paramter after return.

It would be inconsistent. Adjust is called after a raw copy is made,
your subprogram uses a valid type interface instead. And you better
don't do it after Finalize [+ other destructors] were called. Consider
a task object as a member of your limited type.

What you actually describe is a copy constructor, not a subroutine.

---
Regards,
Dmitry Kazakov
www.dmitry-kazakov.de



  reply	other threads:[~2003-07-31 10:26 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-30 11:31 Limited_Controlled types as 'out' arguments Lutz Donnerhacke
2003-07-30 12:22 ` Dmitry A. Kazakov
2003-07-30 12:32   ` Lutz Donnerhacke
2003-07-30 14:24     ` Dmitry A. Kazakov
2003-07-30 14:25       ` Lutz Donnerhacke
2003-07-30 14:48         ` Dmitry A. Kazakov
2003-07-30 15:15           ` Lutz Donnerhacke
2003-07-31 10:26             ` Dmitry A. Kazakov [this message]
2003-07-31 10:54               ` Lutz Donnerhacke
2003-07-31 11:50                 ` Dmitry A. Kazakov
2003-07-31 12:19                   ` Lutz Donnerhacke
2003-07-31 13:15                     ` Dmitry A. Kazakov
2003-07-31 17:51                 ` Randy Brukardt
2003-07-30 15:01         ` Vinzent Hoefler
2003-07-30 15:16           ` Lutz Donnerhacke
2003-07-30 15:52         ` Lutz Donnerhacke
2003-07-30 19:30           ` Randy Brukardt
2003-07-31  7:43             ` Lutz Donnerhacke
2003-07-30 12:31 ` Matthew Heaney
2003-07-30 12:57   ` Lutz Donnerhacke
2003-07-30 13:47     ` Martin Dowie
2003-07-30 17:06     ` Matthew Heaney
2003-07-30 12:37 ` Martin Dowie
2003-07-30 12:59   ` Lutz Donnerhacke
2003-07-30 13:41     ` Martin Dowie
replies disabled

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