From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,73f81e5f5d6ee80f X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!nx01.iad.newshosting.com!newshosting.com!83.128.0.12.MISMATCH!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!feeder.news-service.com!news.astraweb.com!border3.a.newsrouter.astraweb.com!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: MI is sloppy Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <493ab375$0$31872$9b4e6d93@newsspool3.arcor-online.net> Date: Sun, 7 Dec 2008 10:12:40 +0100 Message-ID: <10wio06m42skd$.11t1wjs299ul4$.dlg@40tude.net> NNTP-Posting-Date: 07 Dec 2008 10:12:41 CET NNTP-Posting-Host: e8e6dc00.newsspool4.arcor-online.net X-Trace: DXC=l`LmL4?o^2F74okIm;?DS@4IUKCFlCT?[>eX@3M X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:3886 Date: 2008-12-07T10:12:41+01:00 List-Id: 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