comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Help me to chose between ADA 95 and C++
Date: 1999/12/14
Date: 1999-12-14T00:00:00+00:00	[thread overview]
Message-ID: <38566d0a_4@news1.prserv.net> (raw)
In-Reply-To: 38561A6C.5DE3D901@rdel.co.uk

In article <38561A6C.5DE3D901@rdel.co.uk> , Chris Powell 
<chris.powell@rrds.co.uk>  wrote:

> C++ encapsulates methods and data in a single structure. In Ada, class
> methods are defined outside the object type so do not appear to 'belong'
> to the type.

The enclosing package defines what operations are primitive for a type.
So of course the operations are declared "in the type," because they're
in the same package:

package Apples is

  type Apple_Type (<>) is tagged limited private;

  procedure Eat (Apple : access Apple_Type);
...
end Apples;

Procedure Eat is a primitive operation of type Apples.  That's not
obvious?


> Having to explicitly pass the object instance as a parameter (the
> implicit 'this' in C++) further separates the logical association
> between methods and objects.

When I see the procedure declaration:

package Stacks is

  type Stack_Type is limited private;

  procedure Push
    (Item : in     Item_Type;
     On   : in out Stack_Type);
...
end Stacks;


it's perfectly obvious that it's a primitive operation for stacks.

When I see the procedure invocation:

  Push (Item, On => Stack);

it's perfectly obvious that Push is operating on a stack object.

So I don't buy your argument that the syntax "separates the logical
association between methods and objects."

Note also that the Ada95 syntax simplifies binary operations:

  Marry (Adam, Eve);

is a lot more natural than

  Adam.Marry (Eve);



> I am a Multiple Inheritance fan, because I think I know how to use it
> properly. I do not believe it (always) indicates a bad design, as some
> do. Ada 95 has some constructs to allow different types of MI, but not
> all provided by the more general approach of C++, and again, the syntax
> is obscure involving tagged types within generics, access discrimiated
> records, etc. In C++ you simply define an X as a Y and a Z. In Ada, the
> syntax would have been (if allowed):
>
>    type Object is new X.Object and new Y.Object with record ....

Yes, you have to understand how to use access discriminants (to do MI)
and generic formal tagged types (to do mixin inheritance).

The MI and mixin idioms are built on existing language features, so this
keeps the language itself simpler.

I could argue the point the other way.  In C++, the keyword "virtual" is
used so often for so many different things, that it's hard to keep them
all straight.




  parent reply	other threads:[~1999-12-14  0:00 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-26  0:00 Help me to chose between ADA 95 and C++ Robert
1999-11-26  0:00 ` Preben Randhol
1999-11-26  0:00   ` Preben Randhol
1999-11-26  0:00 ` Andreas Winckler
1999-11-26  0:00 ` Harald Schmidt
1999-11-26  0:00   ` Andreas Winckler
1999-11-26  0:00     ` Florian Weimer
1999-12-04  0:00   ` Richard D Riehle
     [not found]     ` <01bf3e32$0b9dc880$022a6282@dieppe>
1999-12-10  0:00       ` Chris Powell
1999-12-13  0:00         ` Marin D. Condic
1999-12-13  0:00         ` Richard D Riehle
1999-12-14  0:00           ` Chris Powell
1999-12-14  0:00             ` Ray Blaak
1999-12-14  0:00             ` Larry Kilgallen
1999-12-15  0:00               ` Robert A Duff
2000-01-12  0:00                 ` Richard Pinkall-Pollei
1999-12-14  0:00             ` Richard D Riehle
1999-12-14  0:00               ` Matthew Heaney
1999-12-14  0:00             ` Simon Wright
1999-12-15  0:00               ` Chris Powell
1999-12-15  0:00                 ` Robert A Duff
1999-12-15  0:00             ` Ted Dennison
1999-12-20  0:00               ` Stefan Skoglund
1999-12-16  0:00             ` Pascal Obry
1999-12-16  0:00               ` Rakesh Malhotra
1999-12-21  0:00                 ` Geoff Bull
1999-12-16  0:00               ` Lutz Donnerhacke
1999-12-16  0:00               ` Aidan Skinner
1999-12-21  0:00             ` Robert Dewar
1999-12-21  0:00               ` Ted Dennison
1999-12-21  0:00                 ` Robert Dewar
1999-12-21  0:00               ` Chris Powell
1999-12-13  0:00         ` DuckE
1999-12-14  0:00           ` Matthew Heaney
1999-12-13  0:00         ` Brian Rogoff
1999-12-14  0:00           ` Chris Powell
1999-12-14  0:00             ` Preben Randhol
1999-12-14  0:00               ` Stephen Leake
1999-12-14  0:00                 ` Tucker Taft
1999-12-15  0:00                   ` Stephen Leake
1999-12-15  0:00                 ` Preben Randhol
1999-12-14  0:00             ` Brian Rogoff
1999-12-15  0:00           ` Richard Pinkall-Pollei
1999-12-15  0:00             ` Richard Pinkall-Pollei
1999-12-21  0:00             ` Geoff Bull
1999-12-21  0:00               ` Tucker Taft
1999-12-22  0:00                 ` Ted Dennison
1999-12-14  0:00         ` Matthew Heaney
1999-12-14  0:00           ` Chris Powell
1999-12-14  0:00             ` Tucker Taft
1999-12-14  0:00               ` Matthew Heaney
1999-12-23  0:00               ` Chris Powell
1999-12-27  0:00                 ` Robert A Duff
1999-12-14  0:00             ` Matthew Heaney [this message]
1999-12-15  0:00               ` Hyman Rosen
1999-12-14  0:00             ` Stephen Leake
1999-12-23  0:00               ` Chris Powell
1999-11-27  0:00 ` Lionel Draghi
  -- strict thread matches above, loose matches on Subject: below --
1999-12-14  0:00 Robert C. Leif, Ph.D.
1999-12-15  0:00 ` Richard D Riehle
1999-12-15  0:00 Robert C. Leif, Ph.D.
1999-12-16  0:00 ` Richard D Riehle
1999-12-16  0:00   ` Matthew Heaney
1999-12-17  0:00     ` Richard D Riehle
1999-12-18  0:00       ` Matthew Heaney
1999-12-20  0:00         ` Richard D Riehle
1999-12-22  0:00 Help me to chose between ADA 95 and C++ ( Ehud Lamm
replies disabled

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