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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: [Newbie] doubly constrained array, dumb question Date: Tue, 27 Feb 2018 16:13:18 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <62f83fe5-15d6-41cf-952f-bc3cb077d42f@googlegroups.com> <473f9b1a-6466-4745-9041-107f54062cf2@googlegroups.com> NNTP-Posting-Host: MyFhHs417jM9AgzRpXn7yg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 X-Notice: Filtered by postfilter v. 0.8.3 Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:50682 Date: 2018-02-27T16:13:18+01:00 List-Id: 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