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,2ff5c149712ec0eb X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.hanau.net!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada Interfaces and the Liskov Substitution Principle 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: <1179953657.839272.160320@a26g2000pre.googlegroups.com> <1179991769.376381.252010@m36g2000hse.googlegroups.com> Date: Thu, 24 May 2007 10:02:08 +0200 Message-ID: <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> NNTP-Posting-Date: 24 May 2007 10:00:01 CEST NNTP-Posting-Host: cca04181.newsspool2.arcor-online.net X-Trace: DXC=O==m3cc>E_C0YVY]kmLTlDA9EHlD;3YcB4Fo<]lROoRA8kFOob@9gk3l>YA X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:15900 Date: 2007-05-24T10:00:01+02:00 List-Id: On 24 May 2007 00:29:29 -0700, Maciej Sobczak wrote: > On 23 Maj, 23:58, "Randy Brukardt" wrote: > >>> My humble opinion: assignment of class-wide types should be prohibited >>> in the first place. I mean - at compile time. >>> It's just asking for troubles. >> >> That doesn't make much sense. Yes, it is a bit weird that assignment is >> potentially a dispatching operation, but otherwise there is no semantic >> problem with it. > > Can it be dispatching on both arguments? It shall be. It is a pity that Ada does not have MD. > If not, how can you reasonably implement it? > > And even if it could, still, how can you *reasonably* implement it? > > Let's take a classic example with the hierarchy of geometric objects > (Object, Rectlangle, Triangle, Circle, and so on) and this: > > procedure Do_Something(X : in Object'Class; Y : out Object'Class) is > begin > Y := X; -- ? > end Do_Something; In the current version of Ada Y is constrained to its actual type. So in all cases of different types you will get Constraint_Error - no full MD. But if there were MD, then you could call Do_Something (Circle, Ellipse). And don't forget: declare X : T'Class := Read_From_File; -- T is non-limited, Adjust is called begin ... > Coming from C++, I have never seen any single example where assignment > made sense with polymorphic hierarchies. Real-life example. Consider a threaded library. Let you have an Ada-like rendezvous. You wanted to propagate an exception raised in the callee to the caller. Similarly, let an exception is propagated out of a child thread. You want to continue its propagation to the parent. > Do you know any such example? Can you show it? Marshaling objects. (All types of, like in the example above, like in view change of a small by-value object, like in making an object persistent or broadcasting it over the network) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de