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: 103376,158ce2376534c35d X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!proxad.net!feeder1-2.proxad.net!news.mixmin.net!news.tornevall.net!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Derived private interface Date: Tue, 26 Jul 2011 16:04:15 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <27656578-65aa-48b9-9f89-4ebd4e0cb02a@glegroupsg2000goo.googlegroups.com> <0fe3b0f8-c064-444d-899d-640e891b58c3@w4g2000yqm.googlegroups.com> <128d8eb5-1cc6-47e3-a09b-b53a5ef289ce@m10g2000yqd.googlegroups.com> <4e141501$0$6629$9b4e6d93@newsspool2.arcor-online.net> <4b2728fc-6127-45d8-a314-9fc491701c26@g12g2000yqd.googlegroups.com> <82vcve4bqx.fsf@stephe-leake.org> <4e15b223$0$6541$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1311714256 26418 69.95.181.76 (26 Jul 2011 21:04:16 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Tue, 26 Jul 2011 21:04:16 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6109 Xref: g2news2.google.com comp.lang.ada:21342 Date: 2011-07-26T16:04:15-05:00 List-Id: "Jeffrey Carter" wrote in message news:j0e0l1$5qh$1@tornado.tornevall.net... > On 07/22/2011 03:59 PM, Randy Brukardt wrote: >> >> Given that the problem in question is related to dynamic dispatching and >> has >> nothing in particular to do with extensions, this is an amazing >> statement. > > My statement was tongue in cheek, intended to express my dislike for > tagged types. Their only value seems to be all the traffic here from > people who run into problems trying to use them; this would be a much > quieter place without them. > > Maybe I'm missing something, but it seems to me that all dispatching in > Ada is related to extensions. If you have > > type T is tagged ... > > procedure P (V : in out T); > > and you never extend T, then you never get dispatching (in the sense that > a call to P results in something other than this P being called). To get > dispatching, you have to extend T > > type T2 is new T with ... > > overriding procedure P (V : in out T2); > > Then you can get a single call that sometimes calls P for T and other > times P for T2; that's dispatching. I don't know what dispatching means > without an extension and an overridden subprogram to dispatch to. You're right in language terms, but as Dmitry points out, this occurs only because we're discussing tagged types (which include 3 of the 4 OOP legs in a single package). I was thinking more generally (and yes, I just complained about Dmitry doing that); what I was thinking of by "extension" was actually adding components to a type, not just deriving a a type with the same set of components. As I was describing, most of the use of dispatching in Claw does not use any extension (that is, adding new components), it just changes the behavior of the dispatching routines appropriately. So there is only a change in behavior, not a change in representation. Others have pointed out that using case statements as you suggested is essentially worthless unless you know every entity that the program is going to process before the fact. And real world programs are not like that (I have plenty of experience changing hundreds of case statements each time we make a change in node types or intermediate code definitions in Janus/Ada). Randy. >> OTOH, programming by composition would provide nothing, in that there >> would >> be no way to change the handlers for the base type. One could graft some >> sort of unstructured mechanism on top of the objects (possibly using >> access-to-subprograms), but this would provide many more opportunities >> for >> mistakes (if you forget to set the access-to-subprogram value, the >> routine >> might as well not exist). > > The equivalent of dispatching in programming by composition is a > subprogram that contains a case statement that contains calls to other > subprograms. No access-to-subprogram values involved. It does the exact > same thing as dispatching, except that it's easier to read and understand > and doesn't result in large numbers of "what am I doing wrong?" posts to > c.l.a. > >> Remember that there are four legs to the OOP stool: strong typing, >> encapsulation, extension, and dynamic dispatching -- and each of these is >> orthogonal to the others (shown by the fact that Ada has the first two >> without even using tagged types, that is OOP). So there is no necessary >> relationship between extension and dispatching (and working around the >> one >> does nothing to solve a problem that mainly depends on the other). > > Again, I have no idea what dispatching even means in the absence of > extension. > > In Ada, "programming by extension" is achieved by the use of tagged types; > it includes dispatching. I have never seen anything implemented using > tagged types that could not also be implemented using programming by > composition. It follows that if there is a case where tagged types cause a > problem, the equivalent solution without tagged types is an effective work > around to the problem. > > Of course, in the case where there is no solution using tagged types, > there may also be no solution without using them. > > -- > Jeff Carter > "If you think you got a nasty taunting this time, > you ain't heard nothing yet!" > Monty Python and the Holy Grail > 23