comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: MI is sloppy
Date: Sun, 7 Dec 2008 10:12:40 +0100
Date: 2008-12-07T10:12:41+01:00	[thread overview]
Message-ID: <10wio06m42skd$.11t1wjs299ul4$.dlg@40tude.net> (raw)
In-Reply-To: 493ab375$0$31872$9b4e6d93@newsspool3.arcor-online.net

On Sat, 06 Dec 2008 18:16:37 +0100, Georg Bauhaus wrote:

> Dmitry A. Kazakov wrote:
> 
>>    type In_File is ...;
>>    procedure Get (File : in out Input_File; Item : out Data);
>> 
>>    type Out_File is ...;
>>    procedure Put (File : in out Output_File; Item : Data);
>> 
>>    type Inout_File is .. ?
> 
> OK, I can use an object of type Inout_File both as In_File or
> as Out_File.  OTOH, I'm unsure about the notion of Inout_File.

Look at Ada's standard subtypes called "modes." Each Ada type (except
anonymous access) has all of them: "in", "out", "inout", and "constant"
which is merely another name for "in".

> Similarly, is it proper design to make a two-way street appear to
> have only one polymorphic lane, i.e. think of streets as objects of
> a single MI type? I wouldn't want to drive there unless a big, proven
> apparatus of typing machinery, calling protocol, etc. makes sure
> that my car won't be driving along the wrong view of the street.
> I'm not sure but this seems like overhead to me. (Yes, I know there
> are cabins and speed trains and normal trains being directed this
> way. Without MI AFAIK, so I wonder how rail-bound traffic control
> could profit from MI. Will there have to be additional contracts
> for MI type that establish a proper order of object use?)

OK, make the following experiment. Go outside and look at the left side of
the roadway. Cross it to the right side and then turn around 180 degrees.
Study it. Can you note any difference? There is no one! A big advantage,
you know. You don't need another car, another driving license etc in order
to be able to drive back home. In SW we call it reuse. MI is nothing but
reuse.
 
> Can't we just make Inout_File some composition and hide the details
> completely, behind a suitable collection of primitive operations?

A hidden composition does not exist for observers <=> it does not exist at
all. But if you wanted to argue for MI of interfaces (Ada 2005) with an
aggregation behind the scenes, then that obviously would not work. The
diamond diagram is a counterexample:

   type Abstract_File is ...;
   procedure Name (File : Abstract_File) return String;

   type In_File is new Abstract_File ...;
   procedure Get (File : in out Input_File; Item : out Data);
 
   type Out_File is new Abstract_File ...;
   procedure Put (File : in out Output_File; Item : Data);

   type Inout_File is .. ?

No way.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2008-12-07  9:12 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-06 10:09 MI is sloppy (was: Construction initialization problem) Dmitry A. Kazakov
2008-12-06 17:16 ` Georg Bauhaus
2008-12-06 21:16   ` Martin Krischik
2008-12-06 21:35     ` Maciej Sobczak
2008-12-07  9:12   ` Dmitry A. Kazakov [this message]
2008-12-07 15:38     ` MI is sloppy Georg Bauhaus
2008-12-07 20:04       ` Dmitry A. Kazakov
2008-12-11  0:40 ` MI is sloppy (was: Construction initialization problem) Randy Brukardt
2008-12-11 10:02   ` MI is sloppy Dmitry A. Kazakov
2008-12-11 21:44     ` Randy Brukardt
2008-12-11 23:17       ` Georg Bauhaus
2008-12-12 10:06         ` Dmitry A. Kazakov
2008-12-12  9:59       ` Dmitry A. Kazakov
2008-12-12 10:50         ` Georg Bauhaus
2008-12-12 11:15           ` Dmitry A. Kazakov
2008-12-12 12:15             ` Georg Bauhaus
2008-12-12 13:35               ` Dmitry A. Kazakov
2008-12-12 14:29                 ` Georg Bauhaus
2008-12-12 14:59                   ` Dmitry A. Kazakov
2008-12-13  0:08                 ` Randy Brukardt
2008-12-13  9:54                   ` Dmitry A. Kazakov
replies disabled

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