comp.lang.ada
 help / color / mirror / Atom feed
From: Stephane.Barbey@di.epfl.ch (Stephane Barbey)
Subject: Re: Ada Objects  Help!
Date: 23 Jan 1995 11:53:15 GMT
Date: 1995-01-23T11:53:15+00:00	[thread overview]
Message-ID: <1995Jan23.125047@di.epfl.ch> (raw)
In-Reply-To: 1995Jan20.134150@hobbit

From barbey Mon Jan 23 11:51:37 1995
Date: Mon, 23 Jan 95 11:51:34 +0100
From: barbey (Stephane Barbey)
To: hathawa2@marshall.edu (Mark S. Hathaway)
Cc: Stephane.Barbey
Subject: Re: Ada Objects  Help!

In article <1995Jan20.134150@hobbit>, you write:
: > In article <1995Jan16.132400@lglsun.epfl.ch>,
: > nebbe@lglsun.epfl.ch (Robb Nebbe) writes:
: 
: >> In article <3f9g1u$j4m@nps.navy.mil>, swdecato@nps.navy.mil writes:
: 
: >> I wan't to duplicate the following C++ code in Ada.

... but I do not want to duplicate it in this post.


: It's not obvious if 'myclass(int)' is creating a list of objects of type
: myclass or if it's assigning 10 --> dataelement.  It's not very eloquent.

What is obvious is that myclass(int) is a constructor that takes an
integer as a parameter.

: Then the Ada example changes 'myclass(int)' to 'Create(X : Integer) return T'
: with the added complexity of defining T. 

So it is a (member) function that returns an object of type T and takes
an integer as a parameter... It seems to me to be an (almost)
acceptable translation of the C++'s class spec.

: It looks wrong or overly complex.

It isn't wrong. I do not think it is complex either, because the
translation from C++ to Ada 95 is straightforward in this example.

I do not see the complexity in having to define T either. A C++ class
is simultaneously a package and a type, thus the Ada 9X defines a
package and a type. 

I'guess you'll say that it is a lack of unification (See Meyer's seven
sins of OOP), but then, in C++, you find the (strange to me) concept of
having the files (i.e. an OS concept) as a means of modularity, thus
having visibility rules applied to entities defined in the file vs.
other files and visibility rules applied to entities defined in classes
vs. the rest of the world, but the different kind of friends hat have
access to what even your descendants can't see.

Ada has no "bastard unification" between type and class, but unifies
what need to be unified, i.e. packages are the construct to handle
modularity & encapsulation. 

[ObAdvertisement: take a look at my paper in the proceedings of TRI-Ada
94, which handle some of these issues.]


: 
: Here's my idea of how it should look.
: 

[An idea of how it should look in Eiffel++]

: 
: Isn't this closer to what the C++ example is "saying"?
: 

No.

For instance because it is not the same state machine. In your
example, it is possible to call Display between New and Assign, thus it
is possible to try to call Display on an "unitialized" object, which is
not allowed by the C++ spec. Not familiar with oo software testing, are
you?

Note that this is also possible in Rob's spec. (That's why I said that
it was "almost" acceptable.)

My translation would be (by diff'ing Rob's spec):

> package P is  -- Just the specification
>    type T is tagged private;

     type T (<>) is tagged private;
     -- so that no object of T can be created without
     -- initializing it first (here by calling Create).  

>    function Create( X : Integer ) return T;

     function Create (X: Integer) return T'Class;
     -- because in C++, constructor operations are not inherited.
     -- [See my TRI-Ada paper on that point too.] 
      
>    procedure Display( X : T );
> private
>    type T is tagged
>       record
>          Data_Element : Integer;
>       end record;
> end My_Package;

  end P;
  -- to please the compiler.
  

-Stephane

--
Stephane Barbey				"It's not easy getting real wings"	
INJ-335, barbey@di.epfl.ch





      parent reply	other threads:[~1995-01-23 11:53 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3f9g1u$j4m@nps.navy.mil>
     [not found] ` <D2H5un.FEr@nntpa.cb.att.com>
     [not found]   ` <3fcs59$70s@nps.navy.mil>
     [not found]     ` <3ff186$c19@gnat.cs.nyu.edu>
1995-01-17 17:57       ` ADA Objects Help! Mats Weber
1995-01-18 17:47         ` Robert Dewar
1995-01-20 16:04           ` Mats Weber
1995-01-21 18:59             ` Robert Dewar
1995-01-23 12:03               ` Robb Nebbe
1995-01-25 20:44                 ` Mats Weber
1995-01-25 20:44               ` Mats Weber
1995-01-27  4:03                 ` Robert Dewar
1995-01-26  3:36           ` swdecato
     [not found]         ` <3fhggr$11dp@watnews1.watson.ibm.com>
     [not found]           ` <Mats.Weber-1901951739360001@mlma11.matrix.ch>
1995-01-20 17:22             ` Norman H. Cohen
1995-01-23 16:37               ` Mats Weber
1995-01-25 20:44               ` Mats Weber
1995-01-27  4:05                 ` Robert Dewar
1995-01-19 11:57   ` Robert M. Wilkinson
1995-01-22 18:06     ` Robert Dewar
1995-01-24 22:18       ` Norman H. Cohen
1995-01-25  1:26         ` swdecato
1995-01-25 18:18           ` Bob Kitzberger
1995-01-25 20:11             ` Bob Kitzberger
1995-01-26 15:31           ` Norman H. Cohen
     [not found]           ` <D330pK.M1@nntpa.cb.att.com>
1995-01-28 21:46             ` John DiCamillo
1995-01-30 14:13               ` David Emery
1995-01-30 22:50               ` Subject/Object Confusion Syndrome [was: Ada Objects Help] John Volan
1995-02-01 14:33                 ` Norman H. Cohen
     [not found]                   ` <D3DpJu.4nK@swlvx2.msd.ray.com>
     [not found]                     ` <D3H7J3.B2x@inmet.camb.inmet.com>
1995-02-06 10:32                       ` Robb Nebbe
     [not found]                     ` <3gu21g$ch@portal.gmu.edu>
1995-02-06 14:01                       ` John Volan
1995-02-01 22:37                 ` Maarten Landzaat
     [not found]                   ` <3h1ahp$gf5@gnat.cs.nyu.edu>
     [not found]                     ` <3h3jmp$1h1@Starbase.NeoSoft.COM>
1995-02-07 14:39                       ` John Volan
1995-02-09  2:25                         ` David Weller
1995-01-29 18:19             ` ADA Objects Help! mat
     [not found]               ` <1995Feb5.180601@hobbit>
1995-02-07 23:04                 ` Subject/Object Confusion Syndrome [was: Ada Objects Help] John Volan
1995-01-25  9:48       ` ADA Objects Help! mat
1995-01-23 10:01     ` calling syntax (was Re: Ada Objects) Robb Nebbe
1995-01-23 18:08       ` John DiCamillo
1995-01-23 23:47     ` ADA Objects Help! Ed Osinski
1995-01-25  6:19       ` David O'Brien
     [not found] ` <1995Jan16.132400@lglsun.epfl.ch>
     [not found]   ` <131279@cup.portal.com>
1995-01-20 16:52     ` Ada " Robert Dewar
1995-01-22 18:30       ` Tucker Taft
1995-01-24 22:09         ` Jacob Sparre Andersen
1995-01-26 16:20           ` Robert A Duff
1995-01-27 17:04             ` Robert A Duff
1995-01-27 19:58             ` Tucker Taft
1995-01-20 17:41   ` Mark S. Hathaway
1995-01-23 10:41     ` Robb Nebbe
1995-01-23 11:53     ` Stephane Barbey [this message]
replies disabled

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