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,29d8139471e3f53e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Preventing type extensions 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: <87iq2bfenl.fsf@mid.deneb.enyo.de> <874odv9npv.fsf@ludovic-brenta.org> <87y6b7cedd.fsf@mid.deneb.enyo.de> <66a3704c-54f9-4f04-8860-aa12f516134b@t3g2000vbb.googlegroups.com> <87d3sib44t.fsf@mid.deneb.enyo.de> <134q4k2ly2pf4$.17nlv1q6q5ivo.dlg@40tude.net> <4c8dec8e$0$6990$9b4e6d93@newsspool4.arcor-online.net> <8f6cceFrv2U1@mid.individual.net> <18oiywskxfib5.9den27hp0plc.dlg@40tude.net> <8f7fe9F2nlU1@mid.individual.net> Date: Mon, 13 Sep 2010 23:00:40 +0200 Message-ID: NNTP-Posting-Date: 13 Sep 2010 23:00:39 CEST NNTP-Posting-Host: 3518fdab.newsspool4.arcor-online.net X-Trace: DXC=a:m]?:Z_CHhEB;5>eE0T7m4IUK9^TaX1k X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:14060 Date: 2010-09-13T23:00:39+02:00 List-Id: On Mon, 13 Sep 2010 23:21:28 +0300, Niklas Holsti wrote: > Dmitry A. Kazakov wrote: >> On Mon, 13 Sep 2010 13:23:10 +0300, Niklas Holsti wrote: >> >>> Dmitry A. Kazakov wrote: >>> >>>> re-dispatch is the problem, not aggregation or delegation. Don't implement >>>> anything by means of re-dispatch and you will have no "callbacks." A type >>>> extension cannot break anything in the parent's implementation unless it >>>> re-dispatches. >>> Conversely, there are architectures (sensible ones, in my opinion) in >>> which the extension is broken, or is difficult or cumbersome to >>> implement, if the parent does *not* re-dispatch. >> >> I am not sure if these case aren't kludges caused by other language >> deficiencies (e.g. lack of MI, MD, constructors etc). > > I agree that re-dispatching can be used to simulate multiple dispatching > (MD) in Ada. I have no experience of languages that allow multiple > inheritance or multiple dispatch, so they are not in my design tool-kit. > But in the designs where I have used Ada re-dispatching, I don't see how > MI/MD could have replaced re-dispatching; they seem unrelated. The only case where I am really using re-dispatch (though almost always through the Rosen's trick) is layered protocols, where upper levels are defined in terms of lower levels and the latter are implemented very late (e.g. raw I/O operations). I strongly feel that this could be done simpler and safer using MI and possibly MD. > That would not have replaced re-dispatching, as I have used it. My > re-dispatching calls are interleaved in a more complex way with the > logic of the calling operation. This is exactly the reason why I am reluctant to use it. I don't want to fight this complexity, things are already complex without that. >> One could consider dispatch restricted to class-wide operations while >> allowing T'Class'Class. Then operations class-wide for T would be primitive >> for T'Class. I.e. one could override them within T'Class'Class. > > I think an example is needed before I can understand that. Which objects > are in T'Class'Class, but not in T'Class? T'Class'Class would be a type which values are of T'Class. Such types would appear if we could derive from T'Class. > Re-dispatching calls from a primitive (non-class-wide) operation can > sometimes be replaced by dispatching calls from a class-wide operation, > and that can clarify a design. Perhaps your suggestion is an extension > of this? When re-dispatch is consistently removed, primitive operations are replaced by class-wide ones. Sometimes you want to replace a class-wide operation itself rather than augment it by some primitive operation hook called from it. A consistent way to override a class-wide operation would the class of class-wide types. (I did not much ponder over this model) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de