From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8adc09d3ab9fad6e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-10-08 02:25:08 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: john.nospam@nospamassen.nospamdemon.co.uk (John McCabe) Newsgroups: comp.lang.ada Subject: Re: Ada OO Date: Tue, 08 Oct 2002 09:28:57 GMT Message-ID: <3da2a29d.4879215@news.demon.co.uk> References: NNTP-Posting-Host: pipehawk.demon.co.uk X-Trace: news.demon.co.uk 1034069106 5705 158.152.226.81 (8 Oct 2002 09:25:06 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Tue, 8 Oct 2002 09:25:06 +0000 (UTC) X-Newsreader: Forte Free Agent 1.21/32.243 Xref: archiver1.google.com comp.lang.ada:29577 Date: 2002-10-08T09:28:57+00:00 List-Id: On Tue, 08 Oct 2002 02:17:07 +0000, "Rick Duley" 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.