From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: How to test object hierarchy
Date: Mon, 22 Dec 2003 12:33:45 -0500
Date: 2003-12-22T12:33:45-05:00 [thread overview]
Message-ID: <84ednQiB4Y5nt3qiRVn-hQ@comcast.com> (raw)
In-Reply-To: <bs6fgc$9hpvd$2@ID-77047.news.uni-berlin.de>
Dmitry A. Kazakov wrote:
> This is an argument in favor of implementing MD in Ada, I suppose (:-))
No, it is an argument that current Ada rules are just fine. You can do
multiple dispatching in Ada, and the sort of casual dispatching where
the author of the code doesn't even know that multiple dispatch is
involves works just fine. For example, instantiate a generic with a
classwide type or two as an actual type parameter. The resulting
executable may have nested dispatching, but there is no real need to
anticipate that case when writing the generic.
As for cases where you really NEED to understand the code in multiple
dispatching terms, these are no harder to program in Ada than in other
languages--and no easier. And they really are that hard to wrap the
mind around. There are cases which are worth the effort, but precious few.
Another more prosaic example would be a general graphic file format
converter. I can design such a tool as a combination of a reader and a
writer with a standard intermediate representation:
...
declare
Temp: Intermediate_Format := Read(Input_File);
begin
Write(Temp, Output_File);
end;
Of course I can rewrite this as:
Write(Read(Input_File), Output_File);
Later I might want to add a graphics format that doesn't work well with
the "standard" intermediate format. To do this, I can restructure the
existing code with a multiple dispatch format:
procedure Process(Input: in Graphics_Format; out Graphics_Format'Class);
or
function Process(Input: Graphics_Format) return Graphics_Format'Class;
Now I can provide a body which normally uses the old approach with
Intermediate_Format, but first checks for the special cases and handles
them with other routines.
THAT is when it starts to get difficult to use multiple dispatch. It is
not the process of doing what I call 'casual' multiple dispatch in Ada,
that is easy. The problem is going through on an N**2 case by case
basis (or N**3 or N*M or whatever) and insuring that the approach that
is dynamically selected for that particular case is, in some sense, the
right one. And when the set of possibilities grows, adding one new
format means considering 2N-1 new cases.
--
Robert I. Eachus
"The war on terror is a different kind of war, waged capture by capture,
cell by cell, and victory by victory. Our security is assured by our
perseverance and by our sure belief in the success of liberty." --
George W. Bush
next prev parent reply other threads:[~2003-12-22 17:33 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-12-18 18:24 How to test object hierarchy Pierre Favier
2003-12-19 0:15 ` Stephen Leake
2003-12-19 7:45 ` Pierre Favier
2003-12-19 10:53 ` Dmitry A. Kazakov
2003-12-19 14:35 ` Hyman Rosen
2003-12-19 17:07 ` Dmitry A. Kazakov
2003-12-19 23:26 ` Robert A Duff
2003-12-20 18:20 ` Robert I. Eachus
2003-12-19 17:25 ` Georg Bauhaus
2003-12-20 11:13 ` Dmitry A. Kazakov
2003-12-21 4:34 ` Georg Bauhaus
2003-12-21 13:43 ` Dmitry A. Kazakov
2003-12-21 19:58 ` Dmytry Lavrov
2003-12-22 1:19 ` Robert I. Eachus
2003-12-22 10:09 ` Dmitry A. Kazakov
2003-12-22 17:33 ` Robert I. Eachus [this message]
2003-12-23 10:49 ` Dmitry A. Kazakov
2003-12-22 10:05 ` Dmitry A. Kazakov
2003-12-19 17:24 ` Nick Roberts
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox