comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: OOP & Packages in Ada
Date: 1998/02/01
Date: 1998-02-01T00:00:00+00:00	[thread overview]
Message-ID: <34d4c2c4.1006908@SantaClara01.news.InterNex.Net> (raw)
In-Reply-To: 6b1atp$ngp$1@Masala.CC.UH.EDU


Is this what you want:
package parent is
  type mammal is tagged null record;
  procedure eat(x : in out mammal);
end parent;

with ada.text_io;
package body parent is
  procedure eat(x : in out mammal) is
  begin ada.text_io.put_line("eat");end eat;
end parent;

with parent;
package child is
  type dog is new parent.mammal with null record;
  procedure bark(x : in out dog);
end child;

with ada.text_io;
package body child is
  procedure bark(x : in out dog) is
  begin ada.text_io.put_line("bark");end bark;
end child;

with child;
procedure user is
  rover : child.dog;
begin
  child.bark(rover);
  child.eat(rover);
end user;
    Note that primitive operations are inherited by child and appear
to user as if child declared them.  This isn't so for other things -
other types, constants, variables, etc.  For instance, if we add
  epitome : mammals;
to the spec of parent, this does not produce a child.epitome (clearly
such a beast would be expected to be different anyway).  If user
wanted to refer to the epitome of mammals, he would "with parent" and
reference parent.epitome.  (Not good naming here, sorry.)  
  The primitive operations supplied by a child may replace or
supplement, or both, those supplied by the parent.




  reply	other threads:[~1998-02-01  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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
replies disabled

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