comp.lang.ada
 help / color / mirror / Atom feed
From: Laurent Guerby <guerby@acm.org>
Subject: Re: Ada OO Mechanism
Date: 1999/05/26
Date: 1999-05-26T19:44:32+00:00	[thread overview]
Message-ID: <86iu9fhawg.fsf@ppp-101-91.villette.club-internet.fr> (raw)
In-Reply-To: t7g14lrlag.fsf@calumny.jyacc.com

Hyman Rosen <hymie@prolifics.com> as
> I believe this Ada --
> 
>    generic
> 	type S is abstract tagged private;
>    package P is
> 	type T is abstract new S with private;
> 	-- operations on T
>    private
> 	type T is abstract new S with
> 	   record
> 	      -- additional components
> 	   end record;
>    end P;
> 
> corrsponds to this C++ --
> [...]

As for your quest of finding an example of an OO construct
significantly easier in Ada than in C++, I don't think you'll find
something were the difference in implementation is that great, the OO
models are basically the same (but for multiple inheritance of
course).

I don't know if in C++ you can constrain a template type argument to
be of a specific class (type and class in the Ada sense). Here is a
slight variation of the Ada code you posted that uses this feature:

package P is
   type T is tagged null record;
   -- T ops
end P;

with P;
generic
   type GT is new P.T with private;
   --  This generic can be instanciated with any type in T'Class
package G is
   -- I can call T ops on GT objects.
   type GGT is new GT with null record;
   -- GGT has T ops too.
end G;

The Ada OO model guarantees that no dispatch operation will run
non-existing code (even in case of wild generics), I don't know if
it's true of the C++ one. Okay, it doesn't make any OO construct
easier, but you feel safer when this property is true ;-).

Not directly linked to OO constructs (I agree in advance ;-):

* In Ada, with discriminants you can easily have objects of varying
size being stack allocated instead of heap allocated. On the notation
size, I believe the Ada and C++ (vector<>) ways are equivalent but when
you put parallelism in the loop it doesn't look quite the same, heap
is global data so you have to lock when you use it, which can be
troublesome in some cases performance-wise.

* I don't know if self referencial types have a C++ equivalent (see
the Ada rationale for an example of such beast).

* You can "statically" create complex objects and elaboration issues
are correctly handled by the Ada definition, I don't think it's the
case in C++ (I think you don't know in what order the constructors
will be called for "static" data in C++, I might be wrong).

* What happens if a constructor or a destructor (C++ terminology)
raises an exception is fully specified in Ada, in particular in case
of a destructor exception, for each object in the scope its destructor
is given a chance to run, when this is done a big general ooops
exception is raised. I don't know if it is the case in C++.  This
applies too to function returning objects called as argument of
another subprogam.

--LG




  parent reply	other threads:[~1999-05-26  0:00 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-20  0:00 Ada OO Mechanism Shawn M. Root
1999-05-20  0:00 ` Samuel Mize
1999-05-20  0:00   ` David Botton
1999-05-20  0:00     ` Samuel Mize
1999-05-20  0:00       ` David Botton
1999-05-24  0:00   ` Hyman Rosen
1999-05-24  0:00     ` Robert Dewar
1999-05-24  0:00       ` Hyman Rosen
1999-05-24  0:00         ` David Starner
1999-05-24  0:00           ` bob
1999-05-24  0:00             ` David Starner
1999-05-25  0:00               ` Ole-Hjalmar Kristensen
1999-05-25  0:00                 ` Mark A Biggar
1999-05-25  0:00                   ` Hyman Rosen
1999-05-25  0:00                     ` Richard D Riehle
1999-05-25  0:00                       ` David Botton
1999-05-26  0:00                         ` Tom Moran
1999-05-27  0:00                       ` Aidan Skinner
1999-05-25  0:00                     ` Samuel Mize
1999-05-25  0:00                       ` Hyman Rosen
1999-05-25  0:00                         ` Richard D Riehle
1999-05-25  0:00                           ` Hyman Rosen
1999-05-26  0:00                             ` Ray Blaak
1999-05-26  0:00                               ` Richard D Riehle
1999-05-26  0:00                                 ` Hyman Rosen
1999-05-27  0:00                                   ` Richard D Riehle
1999-06-05  0:00                                     ` Matthew Heaney
1999-06-07  0:00                                       ` Hyman Rosen
1999-05-28  0:00                                   ` Laurent Guerby
1999-06-05  0:00                                   ` Matthew Heaney
1999-06-07  0:00                                     ` Hyman Rosen
1999-06-08  0:00                                       ` Matthew Heaney
1999-06-08  0:00                                         ` Hyman Rosen
1999-06-08  0:00                                           ` Samuel Mize
1999-06-08  0:00                                             ` Hyman Rosen
1999-06-08  0:00                                       ` Robert Dewar
1999-06-08  0:00                                         ` Stanley R. Allen
1999-06-08  0:00                                         ` Markus Kuhn
1999-06-08  0:00                                           ` Stanley R. Allen
1999-05-26  0:00                               ` Hyman Rosen
     [not found]                           ` <t7zp2sr6yf.fsf@calumny.jyacc.c <t7r9nmz8ou.fsf@calumny.jyacc.com>
1999-06-08  0:00                             ` Larry Kilgallen
1999-06-08  0:00                               ` Hyman Rosen
1999-06-14  0:00                                 ` Robert A Duff
     [not found]                           ` <t7zp2sr6yf.fsf@calumny.jyacc.c <t7emjmmx8w.fsf@calumny.jyacc.com>
1999-06-08  0:00                             ` Larry Kilgallen
1999-06-08  0:00                               ` Hyman Rosen
1999-06-08  0:00                                 ` Tucker Taft
1999-06-08  0:00                                   ` Brian Rogoff
     [not found]                                   ` < <375E92CB.27850620@averstar.com>
1999-06-09  0:00                                     ` Brian Rogoff
1999-06-14  0:00                                       ` Robert A Duff
1999-06-09  0:00                                   ` Robert Dewar
1999-06-09  0:00                                   ` Tucker Taft
1999-06-09  0:00                                 ` Samuel Mize
1999-06-09  0:00                                 ` Matthew Heaney
     [not found]                           ` <t7zp2sr6yf.fsf@calumny.jyacc.c <375d9a3d.e1cccc63@averstar.com>
1999-06-09  0:00                             ` Larry Kilgallen
1999-06-09  0:00                               ` Tucker Taft
1999-05-25  0:00                         ` Samuel Mize
1999-05-25  0:00                           ` Chris
1999-05-25  0:00                             ` David Botton
1999-05-27  0:00                               ` Aidan Skinner
1999-05-27  0:00                                 ` Gautier
1999-05-27  0:00                             ` Samuel Mize
1999-05-25  0:00                         ` Brian Rogoff
1999-05-25  0:00                           ` Jim
1999-05-26  0:00                           ` Robert Dewar
1999-05-26  0:00                             ` Brian Rogoff
1999-05-27  0:00                         ` Samuel Mize
1999-05-27  0:00                           ` Hyman Rosen
1999-05-28  0:00                             ` Samuel Mize
1999-05-28  0:00                             ` Laurent Guerby
1999-05-28  0:00                               ` Richard D Riehle
1999-05-28  0:00                                 ` Tom Moran
1999-05-27  0:00                         ` Samuel Mize
1999-05-27  0:00                           ` Jon S Anthony
1999-05-28  0:00                     ` Robert I. Eachus
1999-05-28  0:00                       ` Brian Rogoff
1999-05-29  0:00                       ` Ehud Lamm
1999-05-30  0:00                         ` chris
1999-05-30  0:00                           ` Robert Dewar
1999-05-30  0:00                           ` Harry George
1999-05-30  0:00                             ` Vladimir Olensky
1999-05-31  0:00                               ` Robert Dewar
1999-05-31  0:00                           ` Vladimir Olensky
1999-06-03  0:00                             ` Dale Stanbrough
1999-06-02  0:00                               ` mike
1999-06-03  0:00                                 ` Robert Dewar
1999-06-06  0:00                                   ` David Botton
1999-06-07  0:00                                     ` Robert Dewar
1999-06-01  0:00                           ` Richard D Riehle
1999-06-03  0:00                         ` Matthew Heaney
1999-06-03  0:00                     ` Matthew Heaney
1999-05-25  0:00                 ` Florian Weimer
1999-05-24  0:00         ` Mike
1999-05-25  0:00           ` Robert Dewar
1999-05-25  0:00     ` Samuel Mize
1999-05-25  0:00       ` Hyman Rosen
1999-05-25  0:00         ` David Starner
1999-05-26  0:00         ` Laurent Guerby [this message]
1999-05-26  0:00           ` Hyman Rosen
1999-05-28  0:00             ` Laurent Guerby
1999-06-01  0:00               ` Hyman Rosen
1999-06-03  0:00                 ` Fraser Wilson
1999-05-26  0:00         ` Ole-Hjalmar Kristensen
1999-06-03  0:00     ` Matthew Heaney
1999-06-03  0:00       ` Hyman Rosen
1999-05-21  0:00 ` Dale Stanbrough
1999-05-20  0:00   ` bob
1999-05-21  0:00     ` Dale Stanbrough
1999-05-21  0:00   ` Richard D Riehle
1999-05-21  0:00     ` Shawn M. Root
1999-05-21  0:00       ` Richard D Riehle
1999-05-25  0:00         ` Shawn M. Root
1999-05-21  0:00     ` Marin David Condic
1999-05-21  0:00       ` Steve
1999-05-21  0:00       ` Dan Nagle
1999-05-24  0:00         ` Marin David Condic
1999-05-25  0:00   ` Don Overheu
replies disabled

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