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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,98f446539174ef31 X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: Re: OOP & Packages in Ada Date: 1998/02/01 Message-ID: <34d4c2c4.1006908@SantaClara01.news.InterNex.Net>#1/1 X-Deja-AN: 321136876 References: <6asp37$q8b$1@Masala.CC.UH.EDU> <6b1atp$ngp$1@Masala.CC.UH.EDU> Organization: InterNex Information Services 1-800-595-3333 Newsgroups: comp.lang.ada Date: 1998-02-01T00:00:00+00:00 List-Id: 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.