From: Shark8 <onewingedshark@gmail.com>
Subject: Re: How to stop inheritance in a good way?
Date: Fri, 17 Jan 2020 05:39:57 -0800 (PST)
Date: 2020-01-17T05:39:57-08:00 [thread overview]
Message-ID: <105a6e35-6df5-446e-b959-09680044c960@googlegroups.com> (raw)
In-Reply-To: <755521b8-d0a8-41bd-b547-da1136e3b8e1@googlegroups.com>
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;
next prev parent reply other threads:[~2020-01-17 13:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-15 8:32 How to stop inheritance in a good way? reinert
2020-01-15 9:08 ` Dmitry A. Kazakov
2020-01-15 20:56 ` Randy Brukardt
2020-01-15 23:19 ` Jere
2020-01-17 9:48 ` reinert
2020-01-17 21:17 ` Optikos
2020-01-17 13:39 ` Shark8 [this message]
2020-01-20 4:32 ` ric.wai88
2020-01-17 16:56 ` AdaMagica
2020-01-17 23:51 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox