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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:7b9b:: with SMTP id p27mr7671614qtu.2.1579268397809; Fri, 17 Jan 2020 05:39:57 -0800 (PST) X-Received: by 2002:a05:6830:1d7b:: with SMTP id l27mr5745836oti.251.1579268397481; Fri, 17 Jan 2020 05:39:57 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!g89no6207558qtd.0!news-out.google.com!w29ni1526qtc.0!nntp.google.com!g89no6207553qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 17 Jan 2020 05:39:57 -0800 (PST) In-Reply-To: <755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=146.5.2.231; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 146.5.2.231 References: <755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <105a6e35-6df5-446e-b959-09680044c960@googlegroups.com> Subject: Re: How to stop inheritance in a good way? From: Shark8 Injection-Date: Fri, 17 Jan 2020 13:39:57 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57861 Date: 2020-01-17T05:39:57-08:00 List-Id: On Wednesday, January 15, 2020 at 1:32:14 AM UTC-7, reinert wrote: > > and I want object2_2_t *not* to inherit the function B (from type object1_t). Well, there's two ways that you could do this: (1) If you don't need to pass the object to Object1_T'Class parameters or do inline view-conversions then simply make Object2_T a private type, copying over the interface you want to expose, with the inheritance in the full-view. (2) If you need to ensure that there is direct/visible inheritance, you could use generics and the "is null" default on functions to control behavior. GENERIC Type XX(<>) is abstract new Object2_T with private; -- You could use Int1_T. with Function A_Implementation(X : XX) return Integer is null; with Function B_Implementation(X : XX) return Integer is null; --... Package Selective is Type Child is new XX with null record; Overriding Function A( Object : Child ) return Integer; --... Private Function A( Object : Child ) return Integer is ( A_Implementation(XX(Object)) ); --... End Selective;