comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: OO in Ada
Date: Tue, 8 Oct 2002 11:37:42 -0400
Date: 2002-10-08T11:37:42-04:00	[thread overview]
Message-ID: <uq5uu7e7rc623a@corp.supernews.com> (raw)
In-Reply-To: 3da2aafd.7023559@news.demon.co.uk


"John McCabe" <john.nospam@nospamassen.nospamdemon.co.uk> wrote in message
news:3da2aafd.7023559@news.demon.co.uk...
>
> 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.

This isn't quite right.  There is *always* inheritance when a type derives
from another type.  If the parent type is tagged, then you're allowed to
extend the parent type's representation.

What you really meant is that you don't have *visibility* to the parent's
private presentation, unless the type is declared in a child package.

If you derive from a type, you always inherit its representation and
operations (that's what "primitive  operation" means).

> >:)  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.

Yes, something is indeed wrong with the parent declaration.  If the
operation is primitive, then it gets inherited.
_There_is_always_inheritance_of_primitive_operations.

> >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.

Why is

package P is
   type T is tagged limited private;
   function "=" (L, R : T) return Boolean;
  ...
end;

any different from:

namespace N
{
   class C
   {
      ...
   private:
      C& operator=(const C&);
      C(const C&);
   };

   bool operator==(const C& lhs, const C& rhs);
}

Are you saying binary operations in C++ aren't intuitive?

If I do this:
   Push_Back (List, Item);

then is there any question that I'm appending a new element, with the value
Item, to the back of object List?







  reply	other threads:[~2002-10-08 15:37 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-10-04  2:14 OO in Ada Rick Duley
2002-10-04  2:55 ` Jim Rogers
2002-10-04 17:35   ` Hyman Rosen
2002-10-05  0:20     ` Jim Rogers
2002-10-05 23:38       ` Dmitry A.Kazakov
2002-10-05 15:25         ` Jim Rogers
2002-10-06 21:37           ` Dmitry A.Kazakov
2002-10-06  2:18       ` Hyman Rosen
2002-10-06  3:00         ` Jim Rogers
2002-10-08 21:08           ` Gisle Sælensminde
2002-10-04  3:37 ` Chad R. Meiners
2002-10-04  5:32 ` Simon Wright
2002-10-04  6:01 ` tmoran
2002-10-04 15:05 ` Matthew Heaney
2002-10-05  2:14 ` SteveD
2002-10-05  8:54   ` Preben Randhol
2002-10-07 14:10   ` Matthew Heaney
2002-10-07 19:52     ` Jeffrey Carter
2002-10-08 21:18     ` Dmitry A.Kazakov
2002-10-08  9:53 ` John McCabe
2002-10-08 15:37   ` Matthew Heaney [this message]
2002-10-08 16:47     ` Georg Bauhaus
2002-10-08 17:48       ` Matthew Heaney
2002-10-08 17:16     ` Warren W. Gay VE3WWG
2002-10-08 17:58       ` Matthew Heaney
2002-10-09 16:59         ` Warren W. Gay VE3WWG
2002-10-08 10:21 ` Preben Randhol
  -- strict thread matches above, loose matches on Subject: below --
1998-05-15  0:00 Gisle S{lensminde
replies disabled

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