comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Limited use for limited with?
Date: Wed, 13 Oct 2010 02:43:51 -0700 (PDT)
Date: 2010-10-13T02:43:51-07:00	[thread overview]
Message-ID: <5b342ba5-5559-4f46-b48a-fc9436da1fd1@y31g2000vbt.googlegroups.com> (raw)
In-Reply-To: i934cs$201$1@munin.nbi.dk

On 13 Paź, 04:09, "Randy Brukardt" <ra...@rrsoftware.com> wrote:

> >> IMHO, Interfaces are worthless.
>
> >I hope you understand that this is a very strong statement. It
> >basically stands in direct opposition to the work that has been done
> >to introduce them into the language.
>
> I DID a lot of that work. [...]
> we added it for them, not for me!

This shows that there are very interesting forces in action in ARG.
While we're at it, I believe that real multiple inheritance would be
much better solution, but I accept interfaces as something that is
still useful. Not having both of them would be very limiting.

> >No, not at all. The type safety is not compromised in any way.
> >Consider:
>
> >   procedure Handle_Event (H : Handler_Access; Data : in Integer);
>
> >(where type Handler_Access is access all Handler'Class)
>
> >In what way is the type safety of Data compromised here?
>
> It's not. But it is highly unlikely that different events need the same
> data. So you have to have separate event handlers for each event. Once you
> have done that, there no longer is a common mechanism for
> registering/triggering events -- you have to recode it separately for each
> event.

Yes.

> If that's the case, the concerns about coupling are pretty much
> eliminated, as both the object and the event have to know about each other
> anyway.

The decoupling allows to have N similar event sources and M similar
event handlers. I find it frequently the case in control or monitoring
systems, where many measurement systems produce data that can be
processed or displayed by many clients. The decoupling is needed here
so that data sources don't have to *statically* know their receivers.
The "wiring" of the whole is driven by configuration, which is loaded
at run-time.

Georg already described the pattern in more detail, so I will not
repeat it.

> You and I must be thinking of different solutions, because I can't see any
> way for that to work with a single handler registry type. And if you have
> multiple such types, I don't see why you'd want to introduce the
> complication: just deliver the events directly to the appropriate objects.

And here's the catch: event sources don't know their receivers until
the program is run[*], so they cannot deliver the events *directly* to
appropropriate objects. Some level of indirection is needed here and
access values provide the required capability with very little
(negligible) overhead. I think that this is the detail that we have
missed in the discussion up to now.

[*] Actually, the wiring of the components is not necessarily done at
run-time, but certainly later than the event producer is compiled. In
other words, the event producer is compiled as a module and delivered
to the client that adds his handlers. There is no way for the producer
to deliver events *directly* to handlers, as handlers are not known a
priori. And generics are too complex to handle that cleanly.

> >Program safety is not compromised due to the fact that all reasonable
> >use cases guarantee that handlers outlive the registries.
>
> Again, you are saying that no one that will program your system will make a
> mistake.

I'm saying that they will make a lot less mistakes when given a clear
and readable API. The strategy seems to be working so far.

> But I don't
> think you are being realistic: for instance, I want to avoid allocating
> objects when possible, because there are a lot less memory leaks

Again: handlers are not allocated dynamically, they are typically
static entities. Their associations with registries can be dynamic,
though, but there is no danger in it.

> Anyway, I think we have to agree to disagree on this one, because we don't
> even have the same worldview.

I think so.

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



  parent reply	other threads:[~2010-10-13  9:43 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 [this message]
2010-09-28 15:15     ` Ludovic Brenta
2010-09-28 22:04       ` Maciej Sobczak
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