comp.lang.ada
 help / color / mirror / Atom feed
From: ric.wai88@gmail.com
Subject: Re: How to stop inheritance in a good way?
Date: Sun, 19 Jan 2020 20:32:44 -0800 (PST)
Date: 2020-01-19T20:32:44-08:00	[thread overview]
Message-ID: <34fb14e2-45f3-4304-948a-1bb9f39a0e96@googlegroups.com> (raw)
In-Reply-To: <105a6e35-6df5-446e-b959-09680044c960@googlegroups.com>

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..


  reply	other threads:[~2020-01-20  4:32 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
2020-01-20  4:32   ` ric.wai88 [this message]
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