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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: cosc19z5@Bayou.UH.EDU (Spasmo) Subject: Re: Ada95 OOP Questions Date: 1996/07/31 Message-ID: <4toref$ksg@Masala.CC.UH.EDU>#1/1 X-Deja-AN: 171307091 references: <4tf3l4$4hu@masala.cc.uh.edu> <4tgi88$5fi@Masala.CC.UH.EDU> <4tl235$a1v@news.ida.org> organization: University of Houston newsgroups: comp.lang.ada Date: 1996-07-31T00:00:00+00:00 List-Id: David Wheeler (wheeler@aphrodite.csed.ida.org) wrote: : Spasmo (cosc19z5@Bayou.UH.EDU) wrote: [Snip] : : Correct me if I'm wrong on this. So you're still passing parameters : : which means that data and subprograms are still 2 different entities : : which sorta hurts the abstraction, rather than in say C++ where : : you've got a unified object. : I'm afraid you haven't got it. Correction, per your request, follows :-). : In _BOTH_ C++ _AND_ Ada you pass a parameter. : In C++ you say: : p.walk(); : In Ada you say: : walk(p); : IN BOTH CASES YOU PASS A PARAMETER. BOTH. BOTH. BOTH. : When you say "p.walk()" in C++, "p" is the first parameter! *Nod*. It was the syntax that was throwing me for a loop. I saw things done a particular way and immediately thought it to be "THE" way. My mistake. : The only difference is that, to dispatch in C++, you : use a different syntax and the dispatching parameter is listed in : a distinguished position. In C++ the parameter is always called "this". : In Ada, any parameter can be a dispatching parameter, and the : syntax for calling the method doesn't change. : C++ PASSES A PARAMETER. It has to, otherwise how would the : C++ operation being called know which object to work with? Right. [Snip] : : Am I correct or can we in fact inherit operations without manually : : providing wrappers for the predecessors? : You inherit without manually providing wrappers for the : predecessors. That's one of the primary capabilities of Ada 95. : Still in doubt? Go to my example, program Small at : "http://lglwww.epfl.ch/Ada/Tutorials/Lovelace/small.htm". Actually it was your program "Small" that showed me the light so to speak. I wrote some "quick and dirty" code and realized that the children do inherit the operations so we can access parent operations via the children without doing anything. It was just the thought of the parameters influencing inheritance that threw me again. : Click on the package spec for Players -- gee, no operations defined! : Where are they defined? Well, Player is a child of Creature, so click on : that -- still no operations -- click on its parent, Occupant, : and you'll see a whole bunch of operations (and more on its parent, : Thing). You get all the operations of your ancestors, and you : DON'T have to define the wrappers. : Want to see a trivial example of overriding? See Occupant's : May_I_Get method and compare it to Item's May_I_Get method. : The Get command simply calls May_I_Get, dispatching to whichever : version is the correct one for the type. Overriding is no problem. I pretty much have an idea at this point as to what's going on. : IN SUMMARY: : 1. Both C++ and Ada pass parameters to do dispatching. : They have to, otherwise you wouldn't know what you're working on. : 2. Packages are the key Ada structuring mechanism. : 3. Tagged type methods (aka primitive operations) inherit. Thanks a ton for clearing this up! : --- David A. Wheeler : Net address: wheeler@ida.org -- Spasmo "Everyone has secrets, but sometimes you get caught, So if it's just between us, my silence can be bought" "Blackmail" by Sloppy Seconds