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,5c9ae6c7b4ac5676 X-Google-Attributes: gid103376,public From: Matthew J Heaney Subject: Re: Limiting inheritance Date: 2000/07/27 Message-ID: <7rk8e7b4dj.fsf@butter.albany.duck.com>#1/1 X-Deja-AN: 651609409 Sender: mheaney@butter.albany.duck.com References: <8lq7tj$5rt$1@nnrp1.deja.com> X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 964740161 208.136.9.227 (Thu, 27 Jul 2000 16:22:41 PDT) Organization: EarthLink Inc. -- http://www.EarthLink.net NNTP-Posting-Date: Thu, 27 Jul 2000 16:22:41 PDT Newsgroups: comp.lang.ada Date: 2000-07-27T00:00:00+00:00 List-Id: reason67@my-deja.com writes: > package Patch is > > type Patch_Type is (red, orange, yellow, green, blue, violet); > > subtype Base_Patch_Type is Patch_Type Red .. Green; > > type Object is tagged private; > > ... > > procedure Set_Patch_Kind (To : in Base_Patch_Type; In_Object : in > Object); [snip] > package Patch.Fancy is > > subtype Fancy_Patch_Kind is Patch_Kind Blue .. Violet; > > type Object is new Patch.Object with tagged private; > > ... > > procedure Set_Patch_Kind (To : in Fancy_Patch_Type; In_Object : in > Object); > I can make the procedres 2 different names but if I go that route, I > want to NOT inherit the procedure from the parent to the child. Is > there a way to do this? If you don't want the derived type to inherit the operation from its parent, then it sounds like the (parent) operation shouldn't be primitive for the type. If so, there are few things you can do: 1) Declare the operation as a class-wide operation: package Patch is ... procedure Set_Patch_Kind (... In_Object : in Object'Class); ... end Patch; Of course, this operation is now "class"-wide, meaning that it can be used for any type in the class, including fancy-patch objects. This may or may not be what you want. 2) You can declare the operation as a non-class-wide, non-primitive operation, by either 2a) declaring it as a child subprogram: package Patch is ... end Patch; procedure Patch.Set_Patch_Kind (... In_Object : in Object); 2b) declaring it in a nested package: package Patch is ... package Nonprimitive is procedure Set_Patch_Kind (... In_Object : in Object); end; procedure Set_Patch_Kind (...) renames --legal? Nonprimitive.Set_Patch_Kind; ... end Patch; In both 2a) or 2b) the operation takes only objects of exactly type Patch.Object.