From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: [Newbie] doubly constrained array, dumb question
Date: Tue, 27 Feb 2018 16:13:18 +0100
Date: 2018-02-27T16:13:18+01:00 [thread overview]
Message-ID: <p73sid$881$1@gioia.aioe.org> (raw)
In-Reply-To: dc172319-53eb-41fa-ad56-6588fb440080@googlegroups.com
On 27/02/2018 15:34, Jere wrote:
> So the design idea is anything that you actually want to dispatch
> on is relegated to an interface (or multiple interfaces), and you use
> classwide types of the interface to do the dispatching.
I do that in Ada quite customary by declaring an interface before most
of concrete types.
> This makes for
> what is practically a max 1 level deep extension tree.
Not really. It is not a directly related thing.
> Composition
> allows for you to hide non dispatching operations as you see fit (I.E.
> you only implement the ones you want your client to see) while the
> interfaces allow you to cleanly dispatch for operations. You are also
> free to only implement the interfaces you want for each level of
> inheritance. So parent classes can implement interfaces that child
> classes do not.
This is delegation I wanted Ada to have for a long time. Thus would be a
way to work around limitations put upon multiple inheritance. Combined
with declaring interfaces it could be a quite powerful model:
type Interface_T is interface;
procedure Foo (X : Interface_T) is abstract;
type T is new Interface_T ...;
overriding procedure Foo (X : T);
type S is new Controlled and Interface_T ... with record
X : S; -- ARG won't let me derive from T, I do it anyway
end record;
overriding procedure Foo (X : S) is delegated S.X;
Even more flexible if Ada allowed getting interfaces from concrete
types. E.g. instead of
type Interface_T is interface;
procedure Foo (X : Interface_T) is abstract;
type T is new Interface_T ...;
overriding procedure Foo (X : T);
You do
type T is tagged ...;
procedure Foo (X : T);
and use T'Interface instead of explicit declaration of Interface_T.
> I'm not saying this is the end all be all method, but it is definitely
> interesting to tinker with and makes you consider designs a bit
> differently (much like pure composition does).
Everything must be a method = there must be a class for any
type-operation pair.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-02-27 15:13 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-26 16:26 [Newbie] doubly constrained array, dumb question Mehdi Saada
2018-02-26 17:02 ` J-P. Rosen
2018-02-26 21:40 ` Dmitry A. Kazakov
2018-02-26 23:26 ` Randy Brukardt
2018-02-27 9:01 ` Simon Wright
2018-02-27 22:11 ` Randy Brukardt
2018-02-26 20:52 ` Niklas Holsti
2018-02-27 1:29 ` Mehdi Saada
2018-02-27 9:18 ` Dmitry A. Kazakov
2018-02-27 11:43 ` Mehdi Saada
2018-02-27 14:19 ` Dmitry A. Kazakov
2018-02-27 17:08 ` G. B.
2018-02-27 17:37 ` Dmitry A. Kazakov
2018-02-27 14:34 ` Jere
2018-02-27 15:13 ` Dmitry A. Kazakov [this message]
2018-02-27 7:38 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox