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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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!postnews.google.com!o5g2000hsb.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Ada Interfaces and the Liskov Substitution Principle Date: 24 May 2007 05:58:27 -0700 Organization: http://groups.google.com Message-ID: <1180011507.159515.46920@o5g2000hsb.googlegroups.com> References: <1179953657.839272.160320@a26g2000pre.googlegroups.com> <1179991769.376381.252010@m36g2000hse.googlegroups.com> <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> NNTP-Posting-Host: 137.138.37.241 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1180011516 17410 127.0.0.1 (24 May 2007 12:58:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 24 May 2007 12:58:36 +0000 (UTC) In-Reply-To: <12h6mi42jcha0.7f9vfsnihjwr$.dlg@40tude.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10) Gecko/20070228 Red Hat/1.5.0.10-0.1.slc3 Firefox/1.5.0.10,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: o5g2000hsb.googlegroups.com; posting-host=137.138.37.241; posting-account=Ch8E9Q0AAAA7lJxCsphg7hBNIsMsP4AE Xref: g2news1.google.com comp.lang.ada:15904 Date: 2007-05-24T05:58:27-07:00 List-Id: On 24 Maj, 10:02, "Dmitry A. Kazakov" wrote: > > Can it be dispatching on both arguments? > > It shall be. It is a pity that Ada does not have MD. Yes, but that would not automatically solve the problem, see below. > > 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. No, I'm not convinced. This is more like cloning. Assignment of class-wide type is strange/dangerous, beucause it might require dynamic change of the object's type. Assigning Circle to Triangle (through Object'Class) cannot reasonably work with preserving the types of each object. The Triangle would need to become Circle - and this action might change the ability of the object to respond to messages that are supposedly in its interface. Or change the invariants in the original type. declare C : Circle; T : Triangle; begin Do_Something(C, T); -- T := C; inside -- and here some code still thinks that T is a Triangle, -- which according to its declaration in the same scope -- must be true (but isn't!) end; There is no way to change the type of T in the code above and without it there is no way to execute the assignment. You can restrict the operation so that the arguments must have the same tag (and then MD is not needed anymore), but such restriction can be run-time only and cannot be expressed in the signature of Do_Something. Your marshalling example is interesting, but actually works differently: you don't have the left-hand object before assignment; you just make a copy of something and give the copy some identity. It's just a copy-construction basically, or cloning (if polimorphic). You can do this either with access variables or with initialization of class wide type (which is *not* an assignment). I was talking about real assignment - and this assumes that two objects already exist and we make one to be equal to the other. There is no way to do it right. -- Maciej Sobczak http://www.msobczak.com/