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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,4b3c1a8f7db90f9 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!feeder6.cambrium.nl!feed.tweaknews.nl!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng1.kpn.DE!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Interfaces and abstract tagged types Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1w8x4i0peinwk$.16cenhvch5kv5.dlg@40tude.net> Date: Mon, 6 Oct 2008 10:25:08 +0200 Message-ID: NNTP-Posting-Date: 06 Oct 2008 10:25:08 CEST NNTP-Posting-Host: 780619fe.newsspool4.arcor-online.net X-Trace: DXC=TjQ3_mQD2M4NTD55K=4IUK7enW;^6ZC`4IXm65S@:3>?1J`C]i:@W68 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:2246 Date: 2008-10-06T10:25:08+02:00 List-Id: On Sun, 05 Oct 2008 16:29:36 -0400, Robert A Duff wrote: > "Dmitry A. Kazakov" writes: > >> (Interfaces was a huge mistake) > > Interesting. Why do you say so? Because there already existed abstract types for that. One should simply have allowed honest multiple inheritance. The limitation of not having any implementations of primitive operations or component makes just no sense. In fact this artificial limitation is extremely damaging. In one running project, which is Ada 2005, we have huge amounts of code duplication because of this silly constraint. It massively damages reuse: type Read_File is limited interface; type Write_File is limited interface; type Read_Write_File is limited interface and Read_File and Write_File; -- have fun! It seems that the limitation also provokes abstraction inversion and "god-classes." I have had no time to investigate the reasons why, but the effect is noticeable in large projects. Certainly lack of multiple dispatch plays a role here too. Further, interfaces produce lots of noise code when the implementation type and the interface type declarations duplicate each other. The interface cannot be inherited from a concrete type, so one is forced to invent interface, pushing it before the type and then inherit from that. This ends up in a situation when nearly each abstract tagged type is declared as: type A_Interface is limited interface; procedure Foo (X : A) is abstract; type A is abstract ... and A_Interface with ...; overriding procedure Foo (X : A); BTW, this also applies to the standard library. Root_Storage_Pool, Root_Stream_Type, Limited_Controlled etc must have inheritable interfaces. Where are they? The situation is remarkably similar to generics. Same bunch of helper/proxy things. Permanent search for good names for entities which should not existed in first place, an exploding number of packages used in order to keep that rubbish somewhere outside the *code*, which does useful stuff. That hits you back, when you need to understand why the compiler complains about something that does not implement do-not-know-where-declared something, etc. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de