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, 12 Oct 2010 12:29:28 -0700 (PDT)
Date: 2010-10-12T12:29:28-07:00	[thread overview]
Message-ID: <1f38791b-a579-49ed-839c-e6ff3867de76@30g2000yqm.googlegroups.com> (raw)
In-Reply-To: i8uagj$68f$1@munin.nbi.dk

On 11 Paź, 08:23, "Randy Brukardt" <ra...@rrsoftware.com> wrote:

> > There are three options:
>
> >1. index/registry contains the actual objects - this has a big impact
> >on how the objects are created; this might impose limitations that
> >users will not want to accept

> In our case, we did this, because we needed the capability to make the
> object database persistent.

This is not my goal and there is no such requirement in my system, so
I don't consider it a reason for not using access types.

> >3. index/registry contains access values to actual objects

> 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.

> The contortions
> that we've gone through trying to use them for the queue containers

There is no obligation to use them where they are not adequate.
However, this says absolutely nothing about their use in those places
where they *are* useful.

> >So let's be constructive. The problem is the following:
>
> >- there is some activity happening in the environment that generates
> >stimulation that should be handled by the program
> >- there is some common interface for the propagation of this
> >stimulation
>
> I don't believe this is true often enough in practice to be a reasonable
> stipulation.

Let's leave this requirement out of the picture. In fact, this is not
a requirement at all, but since Ada is a strongly-typed language,
there *must* be some specification of the protocol to pass the event
between program modules.

> >- users want to implement their handling routines
> > In short (hey, that's a candidate for a design pattern): Event Handler.

> Generally, such notifications include data.

Typically, yes.

> So you have to deliver the data
> somehow.

Typically, the data will be passed as a parameter of the dispatching
operation that defines the protocol.

> If you use a single interface, you break type safety with accessing
> the data

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?

> In every instance where I've had to do some sort of event handling, I've
> written a separate specification for each handler.

That's OK. These are defined as interfaces in my system.

> You have already decided on a solution, and are trying to shoehorn that into
> Ada.

No. I have reviewed the available language features and I have chosen
the one that allows me to solve the problem in the best way.
You still have not proven it otherwise. :-)

> But you are losing safety: both type safety and program safety (because
> of the dangling pointer issues) by doing so.

Type safety is not compromised. All operations are strongly types.
Some of them might be lately bound (dispatching), but all are strongly
typed. If you think otherwise, please explain.
Program safety is not compromised due to the fact that all reasonable
use cases guarantee that handlers outlive the registries.

> Every solution has tradeoffs,
> and you are picking the one that has the worst attributes from an Ada
> perspective

I'm still waiting for you to show it. And I still don't see it.

> For instance, for Claw, we used OOP dispatching to deliver events. This
> didn't require any Ada registration because Windows (and all other GUIs I've
> looked at) include a window handle in the event message;

GUI has the property that data sources and receivers are (typically)
bound in the 1:1 way. This allowed you to cheat a bit by piggy-backing
the object reference in the window handle.
This is not applicable in general.

> In the Web Server and Spam Filter, the events come from TCP/IP. In this
> case, we don't want a callback per-se because we want to treat each event as
> a "job", and schedule each "job" to be run by one of a pool of tasks.

Yes, this is a possible approach, but tasks and jobs are bound in the
1:N way (that is, each job is delivered to exactly one task). Basic
multitasking patterns involving queues or other buffers are OK for
this.
But it is not applicable in general. Think about how messed up it
would become for N:M case (each job delivered to potentially many
tasks).

It is true that in my system it *would* be possible to do this, but I
have chosen not to do it in order to avoid forcing the user (client
for you) to create additional tasks on his side. It is perfectly
possible to run the whole system in a single-tasking environment -
that is, the one that does not even support multiple tasks. Since my
system is targeted at embedded installations (among others), I
consider this to be an important feature. The user/client can always
add tasking if needed.

> I don't think that there is a general pattern that is acceptable.

I agree. But we are now discussing something different: you seem to
state that *some* pattern is *universally UNacceptable*, no matter
what - and this is something I don't agree with.

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



  reply	other threads:[~2010-10-12 19:29 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 [this message]
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
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