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: a07f3367d7,7ff1de84a8945e80 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!feeder.news-service.com!feeder.erje.net!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Access types as parameters 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: <521c4843-d40f-4545-9e80-ca725e847090@h21g2000yqa.googlegroups.com> <8880c3d0-a07f-4d4e-ac87-372014598576@d15g2000prc.googlegroups.com> <4a83d018$0$26303$4f793bc4@news.tdc.fi> <4a847400$0$26304$4f793bc4@news.tdc.fi> <4a852df2$0$26317$4f793bc4@news.tdc.fi> <1jrxo2acn8evc.x3wfcmp4etbo.dlg@40tude.net> <4a858af5$0$24774$4f793bc4@news.tdc.fi> <4a870a5b$0$26302$4f793bc4@news.tdc.fi> <4a87d705$0$24771$4f793bc4@news.tdc.fi> <4a8807d6$0$24780$4f793bc4@news.tdc.fi> Date: Sun, 16 Aug 2009 19:58:12 +0200 Message-ID: NNTP-Posting-Date: 16 Aug 2009 19:58:08 CEST NNTP-Posting-Host: b54f53d9.newsspool3.arcor-online.net X-Trace: DXC==Pd=b;<;nO6i6K;>iZ]763McF=Q^Z^V384Fo<]lROoR1^YC2XCjHcb9LT1Ca=D7GD;DNcfSJ;bb[5IRnRBaCdI9O@UIaP?o0mi\Sfi1j^^7 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7833 Date: 2009-08-16T19:58:08+02:00 List-Id: On Sun, 16 Aug 2009 16:21:11 +0300, Niklas Holsti wrote: > Dmitry A. Kazakov wrote: >> On Sun, 16 Aug 2009 12:52:53 +0300, Niklas Holsti wrote: >> >>> Although I sometimes do it, I don't much like to inspect tags, as in Foo >>> above, because it couples the logic of a class-wide operation to the >>> existence and properties of certain explicitly named sub-classes, which >>> is fragile. But a redispatching call is not fragile in this way. >> >> It is fragile because it has a behavior that is not determined by the >> values attributed to the type T. Its behavior is determined by the values >> of T'Class, which is an open-ended set. > > No. That argument makes *any* class-wide operation (using dispatching) > "fragile", because "its behaviour is determined by the open-ended set" > of operation implementations. We must accept this kind of "fragility" if > we use dispatching at all. The fragility is not in the set size, but in the operation that handles it implicitly. It is like with side effects. You do one thing, but rely on more than that. Dispatching on the context of the type T it is fragile. On the context of T'Class it is not. >>>> Re-dispatch is a hack. What do you do is >>>> semantically not inheritance but overriding with an instance of a generic >>>> body, or some class-wide body. I think this is the key issue. >>> I'm sorry, I don't understand why it is "semantically not inheritance". >> >> Type S inherits F from T by composition of T.F with a type conversion: >> >> S.F = T.F o S_from_T > > I think you have the conversion the wrong way around: If S.F should > apply to an object X of type S, then X must first be converted to T, and > then T.F applied: > > S.F = T.F o T_from_S Yes. > meaning that > > S.F (X) = T.F (T_from_S (X)) Right. >> That is the only way to define it in a typed language where S and T are >> distinct types. This is also how Ada defines it. Any primitive operation >> gets "re-declared" when you derive S from T. > > Yes, yes, but Ada and other OO languages preserve the ability to > redispatch, which does not fit into this simple mathematical > functional-composition formalism. But then, we agreed that we use > different formalisms, so all is OK. Simple or complex I didn't see different formalisms, that don't fall apart when classes of built-in types come into consideration. Everything is reference? Is reference a reference? etc. And even if re-dispatch could be reconciled with strog typing, an aftertaste remains, to do same thing twice looks wrong. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de