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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!195.197.54.118.MISMATCH!feeder2.news.elisa.fi!newsfeed2.funet.fi!newsfeeds.funet.fi!fi.sn.net!newsfeed1.tdcnet.fi!news.song.fi!not-for-mail Date: Sun, 16 Aug 2009 16:21:11 +0300 From: Niklas Holsti Organization: Tidorum Ltd User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Access types as parameters References: <521c4843-d40f-4545-9e80-ca725e847090@h21g2000yqa.googlegroups.com> <8410fc60-9b8a-4f82-92fc-622a6bbe5931@i18g2000pro.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> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4a8807d6$0$24780$4f793bc4@news.tdc.fi> NNTP-Posting-Host: 81.17.205.61 X-Trace: 1250428886 news.tdc.fi 24780 81.17.205.61:41087 X-Complaints-To: abuse@tdcnet.fi Xref: g2news2.google.com comp.lang.ada:7830 Date: 2009-08-16T16:21:11+03:00 List-Id: Dmitry A. Kazakov wrote: > On Sun, 16 Aug 2009 12:52:53 +0300, Niklas Holsti wrote: > >> Are you saying that any inspection of the tag of an object is >> "bad design", except for the case of "basic" dispatching? > > With a high degree of probability it is. In all cases I have to check tag I > feel myself guilty. Me too. But it is sometimes the best solution (in Ada 95 at least), although it may cause maintenance problems. >> 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. I persist in seeing no extra fragility in redispatching. >>> 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 meaning that S.F (X) = T.F (T_from_S (X)) > 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. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .