comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Self pointer in limited record
Date: Wed, 12 Sep 2007 16:57:05 -0500
Date: 2007-09-12T16:57:05-05:00	[thread overview]
Message-ID: <fc9n64$o81$1@jacob-sparre.dk> (raw)
In-Reply-To: uffdiv96c9bc.6mn4qaig7owe.dlg@40tude.net

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
news:uffdiv96c9bc.6mn4qaig7owe.dlg@40tude.net...
> On Mon, 10 Sep 2007 22:12:47 -0500, Randy Brukardt wrote:
>
> > "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message
> > news:h9v0j8x5uuf3.puwqdmssdfn6$.dlg@40tude.net...
> >> On Mon, 10 Sep 2007 16:27:50 -0000, amado.alves@gmail.com wrote:
> >>
> >>> FWIW, the problem was the following. I am writing a library. I wanted
> >>> to provide a function to the user to allow him to specify the parent
> >>> of an object in a simple way e.g.
> >>>   Parent_Object : Object := Lookup (Name = "foo foo");
> >>>   Object : Object := Create (Name => "bla bla", Parent =>
> >>> Parent_Object);
> >>
> >> What happens when the parent gets finalized before its child? The point
is
> >> that if you have a reference semantics, then probably Object must be a
> >> reference. So access Obkect'Class were a better design. If you want to
hide
> >> references, then you should use smart pointers instead.
> >
> > I disagree. Claw uses a design rather like the one proposed here. All of
the
> > needed references are created inside of the Claw library, and managed
there
> > (with Finalization and Adjust). For instance, if the parent object is
> > finalized, the child object is finalized first (that's necessary because
> > destroying a parent window also destroys any children). If a child
window is
> > finalized, it is unlinked from any lists that it is in.
>
> What happens when somebody would create some of these objects on the
stack?

Works fine -- that's the whole point of this design. When the objects get
finalized, the Claw code for Finalize unlinks them from their parent's list
of children (after destroying any children that they might have). No fuss,
no muss, quite cheap to do, and no dangling pointers.

> You argue for automatic collection, that is my point too. But I would go
> further and hide target objects behind handles to. That would eliminate
> "access." The language problem is though that there is no simple way to
> delegate operations from handle to the target object. It requires a lot of
> work.

Not worth it, because you either lose extension or gain a second level of
tagged types for no real benefit. The Claw design would be a bit more
complex if you wanted the children to survive the destruction of the parent,
but even that wouldn't be very hard or expensive to accomplish. You don't
even need a list of root objects in order to implement this design (Claw has
one for other reasons, but it is only involved in finalization to remove
units from it.)

The biggest annoyance in the Claw design is handling copies, and that really
occurs because the Claw objects probably ought to have been limited, but we
didn't want to give up aggregates and functions (and now we don't have to).

                              Randy.





  reply	other threads:[~2007-09-12 21:57 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-04 19:31 Self pointer in limited record Maciej Sobczak
2007-07-05  8:22 ` Dmitry A. Kazakov
2007-07-05 10:35   ` Maciej Sobczak
2007-07-05 11:01     ` Pascal Obry
2007-07-05 11:14     ` Georg Bauhaus
2007-07-05 12:36     ` Dmitry A. Kazakov
2007-08-31 16:47 ` amado.alves
2007-08-31 17:09   ` Pascal Obry
2007-08-31 17:37   ` Adam Beneschan
2007-08-31 18:26   ` Jeffrey R. Carter
2007-08-31 19:33   ` Dmitry A. Kazakov
2007-09-01 13:33     ` Georg Bauhaus
2007-09-01 13:46       ` Dmitry A. Kazakov
2007-09-01 14:15         ` Georg Bauhaus
2007-09-01 16:03           ` Dmitry A. Kazakov
2007-09-01 19:49             ` Georg Bauhaus
2007-09-01 20:09               ` Dmitry A. Kazakov
2007-09-02 21:37                 ` Georg Bauhaus
     [not found]                   ` <re7ei5lc7dzf$.11qtcnh35jmzg$.dlg@40tude.net>
2007-09-03 10:51                     ` Georg Bauhaus
2007-09-03 14:17                       ` Dmitry A. Kazakov
2007-09-03 15:55                         ` Jean-Pierre Rosen
2007-09-03 19:17                           ` Dmitry A. Kazakov
2007-09-03 19:32                             ` Markus E L
2007-09-03 20:14                             ` Georg Bauhaus
2007-09-04  8:24                               ` Dmitry A. Kazakov
2007-09-04  9:36                                 ` Jean-Pierre Rosen
2007-09-04 10:14                                   ` Dmitry A. Kazakov
2007-09-05 10:49                                 ` Georg Bauhaus
2007-09-05 12:04                                   ` Dmitry A. Kazakov
2007-09-05 13:12                                     ` Jean-Pierre Rosen
2007-09-05 15:10                                       ` Dmitry A. Kazakov
2007-09-05 16:25                                         ` Jean-Pierre Rosen
2007-09-05 19:52                                           ` Dmitry A. Kazakov
2007-09-06  7:19                                             ` Jean-Pierre Rosen
2007-09-06  9:28                                               ` Dmitry A. Kazakov
2007-09-06 11:53                                                 ` Jean-Pierre Rosen
2007-09-06 15:35                                                   ` Dmitry A. Kazakov
2007-09-05 18:31                                     ` Georg Bauhaus
2007-09-05 19:52                                       ` Dmitry A. Kazakov
2007-09-05 21:38                                         ` Georg Bauhaus
2007-09-06  7:37                                           ` Dmitry A. Kazakov
2007-09-06 10:26                                             ` Georg Bauhaus
2007-09-06 12:25                                               ` Dmitry A. Kazakov
2007-09-08  1:27                                               ` Randy Brukardt
2007-09-06  9:14                                         ` Markus E L
2007-09-06  9:48                                           ` Dmitry A. Kazakov
2007-09-04  8:23                             ` Jean-Pierre Rosen
2007-10-31 23:59                           ` adaworks
2007-09-03 20:38                         ` Georg Bauhaus
2007-09-04  8:24                           ` Dmitry A. Kazakov
2007-09-03  7:54             ` Jean-Pierre Rosen
2007-09-01 15:33         ` Markus E L
2007-09-04 14:55           ` Adam Beneschan
2007-09-04 15:09             ` Jean-Pierre Rosen
2007-09-08  1:36               ` Randy Brukardt
2007-09-04 17:31             ` Georg Bauhaus
2007-09-08  1:16     ` Randy Brukardt
2007-09-10 16:27       ` amado.alves
2007-09-10 17:13         ` Adam Beneschan
2007-09-10 19:00         ` Dmitry A. Kazakov
2007-09-11  3:12           ` Randy Brukardt
2007-09-11  9:38             ` Dmitry A. Kazakov
2007-09-12 21:57               ` Randy Brukardt [this message]
2007-09-13  8:03                 ` Dmitry A. Kazakov
2007-09-13 21:37                   ` Randy Brukardt
replies disabled

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