comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Limited use for limited with?
Date: Tue, 28 Sep 2010 15:04:28 -0700 (PDT)
Date: 2010-09-28T15:04:28-07:00	[thread overview]
Message-ID: <a5f6dc73-94ad-4ecc-bec8-c83de1137f2c@x42g2000yqx.googlegroups.com> (raw)
In-Reply-To: 7acf7226-e945-4683-b8a6-ca66f07fe7a1@j24g2000yqa.googlegroups.com

On 28 Wrz, 17:15, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:

> Do you mean you don't like this one:
>
>    procedure Start
>      (Web_Server : in out HTTP;
>       Dispatcher : Dispatchers.Handler'Class;
>       Config     : AWS.Config.Object);
>
> Personally it is the one I prefer. Why do you not like it?

See my answer to Dmitry for code example. The above construct, by
implicitly leaking references out of its execution, obstructs the
scoping of object lifetime.

> > 1. Object is an interface type for the callback that will be
> > implemented by user.
> > 2. Object_Access is a type that will be used for declaring and passing
> > around callback references. I don't want everybody to define their own
> > types for what is a common functionality.
>
> I don't think this functionality is that common; ideally the only
> things you have to do with such references is record them in a
> registry and then dereference them to call the callbacks. You wouldn't
> "pass around" such references very often, I think. Especially if your
> callbacks are allocated at elaboration and not dynamically on the
> heap.

That's right. Still, I need to express it somehow and I think that
having an explicitly defined access type is a good practice.
Unfortunately it does not seem to be compatible with the "limited
with" feature.

> I would probably use an instance of Ada.Containers.Indefinite_Vectors
> or Indefinite_Doubly_Linked_Lists to hold an ordered list of class-
> wide callback objects. Is that the language feature you were looking
> for? Granted, such a container would duplicate the callback objects
> ("functors") in memory; using access values would avoid that.

Exactly, but copying is not the only problem. There are also
dependencies.
Note that my construct is not dependent on Ada.Containers and it
allows the user to write programs without any use of dynamic memory.
It is perfectly possible to create a callback object at the package
level or local in a subprogram.

> I would define the access type in the package that defines the
> registry of callback objects, e.g.
>
> limited with Objects;
> package Registry is
>    type Callback is access all Objects.Object'Class;
>    procedure Register (C : in Callback);
>    procedure Call_All_Callbacks_In_Registration_Order;
> end Registry;

Interesting. I will have to meditate on this possibility.

--
Maciej Sobczak * http://www.inspirel.com



  reply	other threads:[~2010-09-28 22:04 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28  7:37 Limited use for limited with? Maciej Sobczak
2010-09-28  9:04 ` Alex R. Mosteo
2010-09-30  7:24   ` Stephen Leake
2010-09-30  9:21     ` Alex R. Mosteo
2010-09-28  9:18 ` Ludovic Brenta
2010-09-28 12:59   ` Maciej Sobczak
2010-09-28 13:45     ` Dmitry A. Kazakov
2010-09-28 21:57       ` Maciej Sobczak
2010-09-29  6:03         ` Ludovic Brenta
2010-09-29  8:25           ` Maciej Sobczak
2010-09-29  7:51         ` Dmitry A. Kazakov
2010-09-29  8:38           ` Maciej Sobczak
2010-09-29  9:16             ` Dmitry A. Kazakov
2010-09-29 12:22               ` Maciej Sobczak
2010-09-29 13:41                 ` Dmitry A. Kazakov
2010-09-29 15:07                   ` Georg Bauhaus
2010-09-29 19:22                     ` Dmitry A. Kazakov
2010-09-29 20:51                   ` Maciej Sobczak
2010-09-29 21:18                     ` Dmitry A. Kazakov
2010-10-05  7:35                     ` Randy Brukardt
2010-10-08  8:05                       ` Maciej Sobczak
2010-10-09  6:29                         ` Randy Brukardt
2010-10-05  7:25             ` Randy Brukardt
2010-10-08  8:23               ` Maciej Sobczak
2010-10-09  6:13                 ` Randy Brukardt
2010-10-10 14:13                   ` Maciej Sobczak
2010-10-11  6:23                     ` Randy Brukardt
2010-10-12 19:29                       ` Maciej Sobczak
2010-10-12 20:19                         ` Dmitry A. Kazakov
2010-10-13  2:09                         ` Randy Brukardt
2010-10-13  8:44                           ` Georg Bauhaus
2010-10-15  0:59                             ` Randy Brukardt
2010-10-13  9:43                           ` Maciej Sobczak
2010-09-28 15:15     ` Ludovic Brenta
2010-09-28 22:04       ` Maciej Sobczak [this message]
2010-09-28 15:54   ` Robert A Duff
2010-09-30  7:27   ` Stephen Leake
2010-09-30  7:33     ` Ludovic Brenta
2010-09-30 16:03     ` Adam Beneschan
2010-10-07 11:55       ` Stephen Leake
2010-10-07 18:27         ` Martin Krischik
2010-10-07 21:30           ` Adam Beneschan
2010-10-09  6:29             ` Martin Krischik
2010-10-09 18:35               ` Robert A Duff
2010-10-08  0:07           ` Randy Brukardt
2010-10-09  6:21             ` Martin Krischik
2010-09-28  9:32 ` Vadim Godunko
2010-09-28 11:34 ` stefan-lucks
2010-09-28 13:15   ` stefan-lucks
2010-09-28 16:55 ` Adam Beneschan
2010-09-28 17:31   ` Robert A Duff
2010-09-28 19:24     ` Adam Beneschan
2010-09-28 20:32       ` Vadim Godunko
2010-09-28 21:32         ` Adam Beneschan
replies disabled

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