comp.lang.ada
 help / color / mirror / Atom feed
From: Andre Spiegel <spiegel@berlin.informatik.uni-stuttgart.de>
Subject: Re: Ada95 OOP Questions
Date: 1996/07/29
Date: 1996-07-29T00:00:00+00:00	[thread overview]
Message-ID: <lhmvif7ny2a.fsf@berlin.berlin.informatik.uni-stuttgart.de> (raw)
In-Reply-To: 4tf3l4$4hu@masala.cc.uh.edu


Spasmo writes:

> with Persons;
> 
> procedure Main is
> 
> 	P : Persons.Person;
> 
> begin
> 	Persons.Walk(P);
> 	Persons.Talk(P);
> 	Persons.Eat(P);
> end Main;

With a use-clause, it looks better

    with Persons; use Persons;

    P : Person;

    Walk (P);
    Talk (P);
    Eat  (P);

> 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.   

You _are_ wrong.  The subprograms actually _are_ a part of the object,
and they "go" with it, so to speak of, whereever you take the object.
It is just less obvious from the syntax in Ada.

At the implementation level, C++ does things in just the same way as
Ada.  The object *is* actually passed as a parameter to its functions,
although this parameter (the "this" pointer) is implicitly generated.
C++ has a special syntax for method invocation ("p.walk()"), which is
converted to a normal function call with "this=p" as the first
parameter by the compiler.  That is the only difference between C++
and Ada here.  (There are a number of implications of this, though;
mostly concerning the fact that Ada can bind some calls statically,
whereas in C++ you always need to go through the dispatch table in the
object.  I won't go into detail about this here.  Ada gives you finer
control about the calling mechanism, that's the point.)

When you inherit from a type in Ada (extend the type), you certainly
don't need to write the subprograms again -- that's the whole point of
inheritance.  The do "go" with the type; you only need to rewrite
them if you want to change them in the derived type.  No difference
between Ada and C++ here.  The example given in your message is wrong.




  parent reply	other threads:[~1996-07-29  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     ` David Wheeler
1996-07-31  0:00       ` Spasmo
1996-07-30  0:00     ` Ken Garlington
1996-08-04  0:00       ` Spasmo
1996-07-28  0:00 ` David C. Hoos, Sr.
1996-07-28  0:00   ` Spasmo
1996-07-29  0:00 ` Andre Spiegel [this message]
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 ` Robert I. Eachus
1996-07-30  0:00 ` Andre Spiegel
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