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.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to stop inheritance in a good way? Date: Wed, 15 Jan 2020 10:08:41 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com> NNTP-Posting-Host: fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 Content-Language: en-US X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader01.eternal-september.org comp.lang.ada:57845 Date: 2020-01-15T10:08:41+01:00 List-Id: On 2020-01-15 09:32, reinert wrote: > Assume I define a tagged record (or interface) + derived types: > > type int1_t is interface; > function A(x : int1_t) return Integer is abstract; > > type object1_t is abstract new int1_t with private; > function A(x : object1_t) return Integer; > function B(x : object1_t) return Integer; > > type object2_1_t is new object1_t with private; > function C(x : object2_1_t) return Integer; > > type object2_2_t is new object1_t with private; > function D(x : object2_2_t) return Integer; > > and I want object2_2_t *not* to inherit the function B (from type object1_t). > I can make a dummy function B for object2_2_t (to override), but is it a more elegant/proper way? Or I here somehow break the concept of inheritance and enter a "dead end" ? Inherit from object1_t privately? type int1_t is interface; function A(x : int1_t) return Integer is abstract; type int2_t is interface; function B(x : int2_t) return Integer is abstract; type object1_t is abstract new int1_t and int2_t with private; type object2_1_t is new int1_t and int2_t with private; overriding function A(x : object2_1_t) return Integer; overriding function B(x : object2_1_t) return Integer; function C(x : object2_1_t) return Integer; type object2_2_t is new int1_t with private; overriding function A(x : object2_2_t) return Integer; function D(x : object2_2_t) return Integer; private type object2_1_t is new object1_t with ...; type object2_2_t is new object1_t with ...; P.S. The suffix "_t" is really ugly. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de