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!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool2.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: <1180452858.118039.67740@w5g2000hsg.googlegroups.com> <1180510814.812025.251580@u30g2000hsc.googlegroups.com> <1180529642.741098.224230@q66g2000hsg.googlegroups.com> <1ljmbgesxien.syhurcvjdcd2$.dlg@40tude.net> <1180558336.041236.211560@p77g2000hsh.googlegroups.com> <1j91i6rk18kqd.4zjp36eyvps3.dlg@40tude.net> <1180619211.595952.116690@k79g2000hse.googlegroups.com> <1180704750.516171.126220@h2g2000hsg.googlegroups.com> <1r1lyrsyvr52v$.vx1t785sxb9u.dlg@40tude.net> <1180729864.936057.258970@p47g2000hsd.googlegroups.com> <1180802978.626766.128330@h2g2000hsg.googlegroups.com> <2vwm0plnu7gn.172jlansis6fm.dlg@40tude.net> <1180908240.364236.145720@g4g2000hsf.googlegroups.com> Date: Mon, 4 Jun 2007 10:08:30 +0200 Message-ID: <14qx1ctt7r0kf$.on8dfqklv4jk$.dlg@40tude.net> NNTP-Posting-Date: 04 Jun 2007 10:06:05 CEST NNTP-Posting-Host: 8d3e8d31.newsspool2.arcor-online.net X-Trace: DXC=4N[o]I6ZeGIFJ3]dH>I?oEA9EHlD;3YcB4Fo<]lROoRA8kFO76X^?YV>K1H X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:16058 Date: 2007-06-04T10:06:05+02:00 List-Id: On Sun, 03 Jun 2007 15:04:00 -0700, Maciej Sobczak wrote: > On 3 Cze, 09:09, "Dmitry A. Kazakov" > wrote: > >>> Yes, replacement can change the tag. It's the tag of referred object >>> that can change. An access variable can point to Circle and then to >>> Triangle. >> >> No, this is illegal. At least in Ada,: access Circle and access Triangle >> are different types. They cannot be assigned to each other. > > I was talking about access Object'Class with Circle and Triangle being > both derived from Object. What is the difference between the types access T'Class and T'Class? > We are going in circles. I say T'Class should be limited. > Even if T is not. If I'd say access T'Class should be limited even if T is not? > You can theoretize as long as you want and you can say (even rightly) > that replacement is doubly-dispatching, but there *is* a difference > between O(n+m) and O(n*m) - and this difference is what makes > assignment of T'Class simply unrealistic. No, that makes it unrealistic to manage this complexity using crude patterns instead of a consistent approach. The problem is here, the choice is between language support and manual cascaded case-statements. >> The issue of identity / references you are trying to bring in is >> irrelevant. Multiple dispatch assignment is fully applicable to wheel and >> car objects. When you "replace" wheels, you could perform different tasks >> depending on the types of the old and new wheels .How these tasks can be >> encapsulated into one replacement action? > > They are not. That's the feature of replacement. > > This, however, brings another point - if you want to execute different > assignment tasks depending on both LHS and RHS *types*, then let's > extend it a bit: I want to execute different tasks depending on > current *values* of both LHS and RHS. After all, if assignment is > supposed to be doubly-dispatching and if it's also supposed to be no > different than hypothetical Assign(X, Y), then I should be able to do > this, right? Wrong. These are independent. Double dispatch controls the choice of the specific body, it tells nothing about how this body has to be assembled. There could be different ways of doing this, with advantages and disadvantages. In some cases you might really want LHS being finalized before the overridden part of the assignment, like when it holds an expensive resource. Then you have an issue of enforcing finalization on LHS. My approach, not shared here, is that the programmer should have more control over this, when he wants. The constructors, destructors, assignments and aggregates are all polymorphic subroutines composed differently from normal primitive and class-wide operations. In a better language one should be able to describe all these decompositions uniformly, with a higher-level mechanism of polymorphic subprograms. Handling discriminants and types tags is a separate issue of constraint description and propagation. > Right? > Unfortunately, this is completely broken in Ada. It is not broken, it does not exist. Adjust is not an assignment, it is hack to provide functionality without much rethinking. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de