comp.lang.ada
 help / color / mirror / Atom feed
* OOP & Packages in Ada
@ 1998-01-30  0:00 wanker
  1998-01-31  0:00 ` Matthew Heaney
  1998-01-31  0:00 ` Mats Weber
  0 siblings, 2 replies; 14+ messages in thread
From: wanker @ 1998-01-30  0:00 UTC (permalink / raw)




Hey all,

I've got a question for you.  Assuming we have two packages,
say Parents and Children, and Children contains a type,
Child, that is inherited from a type in Parents (Parents.Parent),
is there a way to easily make all the methods of Parents.Parent
available to Child, so that just with'ing the Children package will
make these methods available?  Wrapper functions/procedures
or renaming might do this, but is there an easier way?

Here is an example of what I'm talking about:

[Possibly incorrect Ada source follows, but you get the picture]

In package Parents, there exists the following declarations:

type Parent is tagged 
    record
	...
    end record;

function  X (P : in Parent'Class) returns Integer;
procedure Y (P : in out Parent'Class);
procedure Z (P : out Parent'Class);


And in package Children there exist the following:

type Child is new Parents.Parent with
   record
	...
   end record;


Now let's say we have a main program that withs both of
these packages, so we have something like:

procedure Main is
    P : Parents.Parent;
    C : Children.Child;
begin
   Parents.X (P);
   Parents.X (C);
end Main;

Now, one problem with this code, is that the user seems to have
to know that the method X for C is located in an entirely
different package.  Is there a way to have the package
Children inherit the methods of its parents and make them
visible so they act like it's own?

In other words, is there a way that we can easily make it
so that we can say:
	Children.X (C);

Instead of:
	Parents.X (C);

Without having to do stuff like renaming every function inside
the child?

Thanks





^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~1998-02-06  0:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-30  0:00 OOP & Packages in Ada wanker
1998-01-31  0:00 ` Matthew Heaney
1998-02-01  0:00   ` wanker
1998-02-01  0:00     ` Tom Moran
1998-02-01  0:00     ` Matthew Heaney
1998-02-02  0:00     ` Jon S Anthony
1998-02-02  0:00     ` Anonymous
1998-02-03  0:00     ` John English
1998-02-04  0:00   ` Don Harrison
1998-02-04  0:00     ` Matthew Heaney
1998-02-05  0:00       ` Don Harrison
1998-02-06  0:00         ` Bob Collins
1998-01-31  0:00 ` Mats Weber
1998-01-31  0:00   ` Nick Roberts

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