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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Received: by 2002:ae9:d887:: with SMTP id u129mr45342173qkf.357.1579494765293; Sun, 19 Jan 2020 20:32:45 -0800 (PST) X-Received: by 2002:aca:eb83:: with SMTP id j125mr5940178oih.153.1579494765028; Sun, 19 Jan 2020 20:32:45 -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!g89no2948686qtd.0!news-out.google.com!w29ni1816qtc.0!nntp.google.com!g89no2948675qtd.0!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 19 Jan 2020 20:32:44 -0800 (PST) In-Reply-To: <105a6e35-6df5-446e-b959-09680044c960@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: google-groups.googlegroups.com; posting-host=2607:fea8:6e0:2a7:1858:5b1e:75d9:6f72; posting-account=FIrIqgoAAAAbYWMmVdbV5-vsuCUTq8lA NNTP-Posting-Host: 2607:fea8:6e0:2a7:1858:5b1e:75d9:6f72 References: <755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com> <105a6e35-6df5-446e-b959-09680044c960@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <34fb14e2-45f3-4304-948a-1bb9f39a0e96@googlegroups.com> Subject: Re: How to stop inheritance in a good way? From: ric.wai88@gmail.com Injection-Date: Mon, 20 Jan 2020 04:32:45 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57902 Date: 2020-01-19T20:32:44-08:00 List-Id: On Friday, January 17, 2020 at 8:39:59 AM UTC-5, Shark8 wrote: > 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; Unfortunately you can't use "is null" on functions, only procedures..