comp.lang.ada
 help / color / mirror / Atom feed
From: cosc19z5@Bayou.UH.EDU (Spasmo)
Subject: Re: Ada95 OOP Questions
Date: 1996/07/31
Date: 1996-07-31T00:00:00+00:00	[thread overview]
Message-ID: <4toref$ksg@Masala.CC.UH.EDU> (raw)
In-Reply-To: 4tl235$a1v@news.ida.org


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





  reply	other threads:[~1996-07-31  0:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-28  0:00 Ada95 OOP Questions Spasmo
1996-07-28  0:00 ` Andre Spiegel
1996-07-28  0:00   ` Spasmo
1996-07-29  0:00     ` Thomas Kendelbacher
1996-07-31  0:00       ` Spasmo
1996-08-01  0:00         ` Thomas Kendelbacher
1996-08-02  0:00         ` Gene Ouye
1996-08-01  0:00       ` Jon S Anthony
1996-07-30  0:00     ` Ken Garlington
1996-08-04  0:00       ` Spasmo
1996-07-30  0:00     ` David Wheeler
1996-07-31  0:00       ` Spasmo [this message]
1996-07-28  0:00 ` David C. Hoos, Sr.
1996-07-28  0:00   ` Spasmo
1996-07-29  0:00 ` Andre Spiegel
1996-07-29  0:00   ` David Wheeler
1996-07-30  0:00     ` Spasmo
1996-07-30  0:00     ` Spasmo
1996-07-29  0:00   ` Thomas Kendelbacher
1996-08-02  0:00     ` Robert Dewar
1996-08-05  0:00       ` Thomas Kendelbacher
1996-08-06  0:00         ` Robert Dewar
1996-08-06  0:00           ` Thomas Kendelbacher
1996-08-06  0:00             ` Robert A Duff
1996-08-07  0:00               ` Robert Dewar
1996-08-08  0:00                 ` Robert A Duff
1996-08-09  0:00                   ` Robert Dewar
1996-08-12  0:00             ` Robert I. Eachus
1996-08-08  0:00           ` Theodore E. Dennison
1996-08-09  0:00             ` Robert Dewar
1996-08-12  0:00             ` Joel VanLaven
1996-08-06  0:00         ` Robert I. Eachus
1996-08-10  0:00         ` Chris Morgan
1996-07-30  0:00 ` Andre Spiegel
1996-07-30  0:00 ` Robert I. Eachus
1996-07-30  0:00 ` Andre Spiegel
1996-08-01  0:00 ` Jon S Anthony
1996-08-13  0:00 ` Eric C. Newton
1996-08-14  0:00 ` Eric C. Newton
1996-08-14  0:00 ` Ken Garlington
1996-08-14  0:00 ` Jon S Anthony
1996-08-21  0:00 ` Jon S Anthony
  -- strict thread matches above, loose matches on Subject: below --
1996-08-08  0:00 W. Wesley Groleau (Wes)
1996-08-20  0:00 Farshad Nayeri
1996-08-20  0:00 Farshad Nayeri
1996-08-21  0:00 ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox