comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: memory management in Ada: tedious without GC?
Date: Mon, 19 May 2008 16:16:00 +0200
Date: 2008-05-19T16:16:00+02:00	[thread overview]
Message-ID: <4cui5l7fu3tb.1m4h2ew1xitnp$.dlg@40tude.net> (raw)
In-Reply-To: 48317e39$0$7550$9b4e6d93@newsspool1.arcor-online.net

On Mon, 19 May 2008 15:18:48 +0200, Georg Bauhaus wrote:

> Dmitry A. Kazakov schrieb:
>> On Sun, 18 May 2008 20:50:48 -0700 (PDT), Matthew Heaney wrote:
>> 
>>> On May 16, 4:42 pm, Maciej Sobczak <see.my.homep...@gmail.com> wrote:
>>>> In Ada RAII is realized with controlled types. They are severely
>>>> broken in that they are intrusive in the type hierarchy and they burn
>>>> the whole budget for implementation inheritance,
>>> No, this is wrong.  You can add in Controlled-ness as far down the
>>> hierarchy as you like, by adding a controlled component.
>> 
>> This is broken too:
>> 
>> 1. You don't know exactly the order in which the Finalize of the controlled
>> component gets called.  So if you access the container object over an
>> access discriminant, that might be already invalid.
> 
> When you design a type T, should the aspects of "death"
> of an object affect the "live" aspects of T objects at all?
> Death happens at a defined moment. What happens at this
> moment is conceptually separate from what happens while
> the object is alive, even though there are relations
> between births, lives, and deaths, of course.

When an object is constructed by a public or private composition of other
objects, that breaks this separation. The life span of a component is
longer than of the record it contains. (Exactly same problem arise upon
inheritance.) Thus a component exists before the official birth and after
the death of the whole. The problem is no different from dispatching upon
construction/destruction.

The only solution is to split construction/destruction into multiple
stages, introducing class-wide constructors/destructors. Class here is
"Root_Record_Component_Type'Class."  So when, say, T is put into a record
R, then T inherits from Root_Record_Component_Type and can attach some hook
onto the constructor of the class. That constructor is a part of the
constructor of R'Class. This code will be called after construction of all
components of R and also after construction of R.

In short, T constructed as itself and T constructed as a component of
something else are not equivalent. The latter is more than the former.

> But why lump together these two aspects of dynamics in the
> same type?

Because these are two aspects of the same thing.

> Why not have types, task types perhaps, that take care
> of the post mortem affairs of related types? (Other than
> wasting the bits maybe.)

Why switching context before running a constructor should change anything?
The contradiction to the life span exists independently on that.

> We have Factories. Why not have Incineration_Plants or
> similar, with well defined protocols?
> I certainly find it strange having to think of the
> topological orderings of cleanup work when I focus on
> what objects of a type should actually do (to do ==>
> still alive).

Because these are issues are of the types algebra you have to use in order
to construct the type of the object. If you want that algebra, i.e.
records, arrays, access types construction primitives, then you have to
face the problem.

Object doing things is miles beneath that abstraction level. It's not even
typed. Types operate sets of objects. Algebra of types operates sets of
types.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-05-19 14:16 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-16 17:44 memory management in Ada: tedious without GC? jhc0033
2008-05-16 18:56 ` Ludovic Brenta
2008-05-16 20:42 ` Maciej Sobczak
2008-05-16 21:45   ` Ivan Levashew
2008-05-16 22:59   ` Peter C. Chapin
2008-05-17  5:24     ` jhc0033
2008-05-17  7:50       ` Ivan Levashew
2008-05-16 23:05   ` Randy Brukardt
2008-05-19  3:50   ` Matthew Heaney
2008-05-19  7:55     ` Dmitry A. Kazakov
2008-05-19 13:18       ` Georg Bauhaus
2008-05-19 14:16         ` Dmitry A. Kazakov [this message]
2008-05-23 23:15       ` Robert A Duff
2008-05-24  0:45         ` Randy Brukardt
2008-05-24  8:25         ` Dmitry A. Kazakov
2008-05-24 16:14           ` Robert A Duff
2008-05-24 19:04             ` Dmitry A. Kazakov
2008-05-24 20:52               ` Robert A Duff
2008-05-25  8:12                 ` Dmitry A. Kazakov
2008-05-25 11:28                   ` Maciej Sobczak
2008-05-25 12:35                   ` Robert A Duff
2008-05-26  8:16                     ` Dmitry A. Kazakov
2008-05-24 19:39             ` Georg Bauhaus
2008-05-24 20:45               ` Robert A Duff
2008-05-19  8:35     ` Maciej Sobczak
2008-05-19 15:11       ` Matthew Heaney
2008-05-19 21:13         ` Maciej Sobczak
2008-05-23 23:03         ` Robert A Duff
2008-05-24  0:12           ` Adam Beneschan
2008-05-16 22:45 ` anon
2008-05-17  7:34 ` Pascal Obry
2008-05-17 15:11   ` Bob Klungle
2008-05-17 15:27     ` Pascal Obry
2008-05-17 16:18       ` Georg Bauhaus
2008-05-20  8:04         ` Ole-Hjalmar Kristensen
2008-05-20  8:01       ` Ole-Hjalmar Kristensen
2008-05-20 10:03         ` Martin Krischik
2008-05-17 17:23     ` Martin Krischik
2008-05-17 16:51   ` Maciej Sobczak
2008-05-17 17:45     ` Pascal Obry
2008-05-17 22:28       ` Samuel Tardieu
2008-05-18  7:03         ` Martin Krischik
2008-05-18  8:50           ` jhc0033
2008-05-18  9:31             ` Dmitry A. Kazakov
2008-05-18 14:10               ` Maciej Sobczak
2008-05-18 14:59                 ` Dmitry A. Kazakov
2008-05-18 20:51                   ` Maciej Sobczak
2008-05-19  8:36                     ` Dmitry A. Kazakov
2008-05-18 15:03             ` Martin Krischik
2008-05-18 18:27               ` jhc0033
2008-05-19  4:12                 ` Matthew Heaney
2008-05-19  8:39                   ` Maciej Sobczak
2008-05-19 15:37                     ` Matthew Heaney
2008-05-19 21:21                       ` Maciej Sobczak
2008-05-19 23:02                         ` Matthew Heaney
2008-05-19 10:27                 ` Martin Krischik
2008-05-17 22:42       ` Peter C. Chapin
2008-05-18  6:58         ` Martin Krischik
2008-05-18  6:52     ` Martin Krischik
2008-05-18 14:16       ` Maciej Sobczak
2008-05-17 14:30 ` Brian Drummond
2008-05-17 16:47   ` Maciej Sobczak
2008-05-19 14:45     ` Brian Drummond
2008-05-20  7:42       ` Maciej Sobczak
2008-05-20 18:01         ` jayessay
2008-05-18  8:06   ` Simon Wright
2008-05-18 14:21     ` Maciej Sobczak
2008-05-18 20:48       ` Simon Wright
2008-05-19 14:40     ` Brian Drummond
2008-05-19  3:44 ` Matthew Heaney
replies disabled

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