comp.lang.ada
 help / color / mirror / Atom feed
From: john.nospam@nospamassen.nospamdemon.co.uk (John McCabe)
Subject: Re: Ada OO
Date: Tue, 08 Oct 2002 09:28:57 GMT
Date: 2002-10-08T09:28:57+00:00	[thread overview]
Message-ID: <3da2a29d.4879215@news.demon.co.uk> (raw)
In-Reply-To: mailman.1034043482.7353.comp.lang.ada@ada.eu.org

On Tue, 08 Oct 2002 02:17:07 +0000, "Rick Duley"
<rickduley@hotmail.com> wrote:

>1.   All the texts I can find which deal in any degree at all with OO in Ada 
>teach that the tagged record in an object declaration should be 'private'.  
>When you follow this line, a derived class does not have direct access to 
>the object attributes of the base class, i.e. _there_is_no_inheritace_.

If you make the tagged type declaration private and still want
inheritance your extensions of the tagged type must be created in
child packages of the original tagged type.

>2.   To provide the derived class with access to the object attributes of 
>the base class I have to create user-defined methods in the base class.  

You shouldn't have to do this if you leave the tagged type declaration
public, *or* create the tagged extension in a child package of the
package declaring the base class.

>3.   If the tagged record in the base class is left public and the derived 
>class is in a child package of the package defining the base class, then the 
>base class attributes are accessible to the derived class.  So far so good 

True, but the base class attributes will also be accessible to the
derived class if it is in a child package and the tagged type is
private. A child package always has visibility of its parents' private
parts (so to speak).

>:)  However, if in a program 'use'ing the child package of 'Thick_Pen' (and 
>not mentioning the base package of 'Pen') I make a call to the routine 
>'Draw' with an actual parameter of the type 'Pen' I get a compiler error 
>message to the effect that 'Draw' is not visible.  In other words, Thick_Pen 
>has not inherited the operation Draw for 'Pen'  Again, 
>_there_is_no_inheritace_.

There is an easy answer to this that I can't remember at the moment.
It's probably to do with using 'Class somewhere, but it may be that
you have an incorrect declaration somewhere that isn't actually a
creating a dispatching operation.

>4.  Further along that line, Thick_Pen does not inherit the type Pen so I 
>cannot declare a Pen (or Pen_Access) unless I 'with' and 'use' the package 
>in which Pen is declared.  This means that making the package in which 
>Thick_Pen is declared a child of the package in which Pen is declared 
>totally useless.  _There_is_no_inheritance_!


>I have to say that this is the first time in pretty near a decade I have 
>been writing in and teaching with Ada that Ada hasn't come up with the 
>goods.  Do I labour under some serious misunderstanding, do I have something 
>terribly wrong?

Basically you are making some assumptions based on what you appear to
expect from an object-orientated programming language rather than
looking at the details of how O-O is implemented in Ada 95. Admittedly
the Ada 95 implementation can be a pain in the arse sometimes,
especially if you're used to using C++ and Jave, but there are
generally good reasons for why things are done the way they are. You
need to look at the Rationale to find them out a lot of the time.

>5.   One final thing (for this time anyway ;), why is it that that Ada does 
>not use the intuitive 'object.method' syntax for making calls to and object. 

Go to www.adaic.org and find the Ada 95 Rationale. I believe this is
discussed in there, as are pretty much all of the questions you have
asked to some extent.

>If there are people working on Ada0x then maybe we shoo\uld be putting this 
>forward for consideration.

You haven't been looking at this newsgroup much have you :-)

As David mentioned, it would be worth providing code for this question
rather than your nice class diagrams as the code may tell a different
story.




  reply	other threads:[~2002-10-08  9:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-08  2:17 Ada OO Rick Duley
2002-10-08  9:28 ` John McCabe [this message]
2002-10-08  9:54 ` John McCabe
2002-10-08 18:37   ` tmoran
     [not found] <F44Lnlyg35sQtgTIFpr0000279d@hotmail.com>
2002-10-08  3:01 ` David C. Hoos, Sr.
  -- strict thread matches above, loose matches on Subject: below --
1996-11-25  0:00 Graham Hughes
1996-11-25  0:00 ` Robert A Duff
1996-11-25  0:00   ` Graham Hughes
replies disabled

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