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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1592759aa83d0d45 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-24 05:35:39 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: wojtek@power.com.pl (Wojtek Narczynski) Newsgroups: comp.lang.ada Subject: Re: Suggestion for Ada 200x - Interface inheritance Date: 24 May 2003 05:35:38 -0700 Organization: http://groups.google.com/ Message-ID: <5ad0dd8a.0305240435.337d9373@posting.google.com> References: <0Pxza.699607$OV.652508@rwcrnsc54> NNTP-Posting-Host: 62.111.211.178 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1053779739 14900 127.0.0.1 (24 May 2003 12:35:39 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 24 May 2003 12:35:39 GMT Xref: archiver1.google.com comp.lang.ada:37730 Date: 2003-05-24T12:35:39+00:00 List-Id: "Steve" wrote in message news:<0Pxza.699607$OV.652508@rwcrnsc54>... > Java and C# use the concept of interface inheritance. What do you think of > adding this feature to Ada? > > A tagged type containing only abstract methods (functions and procedures) > would be considered to be an interface. Any tagged type may be dervied from > at most one tagged type containing data elements and any number of > interfaces. > > That is, you may define an interface: > > type interface_example is abstract tagged null record; > > function in_order( obj : interface_example ) return boolean; > > procedure swap( obj1, obj2 : in out interface_example ); > > type data_value is tagged > record > field1 : Natural; > field2 : Natural; > end record; > > type sorted_data is new data_value, interface_example with > record > is_valid : Boolean; > end record; > > The objective is to add interfaces to existing objects such that they may be > used by common routines, in the same way as Java. In fact this might make > it easier to interface with Java. > > Steve > (The Duck) I find your syntax cleaner than the AI proposal: http://www.ada-auth.org/cgi-bin/cvsweb.cgi/AIs/AI-00251.TXT?rev=1.12 This AI has a funny title: "Abstract Interfaces to provide Multiple Inheritance". Two misconceptions: 1. Interfaces cannot be concrete, 2. Interfaces do not provide multiple inheritance. They are just a different solution to to the problem. The AI proposes a new keyword 'interface' which, seems to have no purpose in existence of 'abstract tagged null record'. The new keyword approach also makes it impossible to reuse existing code that declares abstract tagged null records in place of interfaces. Or maybe could the new keyword 'interface' be used interchangably with the (lenthy) 'abstract tagged null record' clause? There is also this weirdness of 'abstract interface' at the begining, but I think the word 'abstract' has been dropped in later stages. The 'type T3 is new T1 and T2 and T3 with null record;' looks is weird as well. A simple comma like in your example is more readable. But I'll welcome whatever comes out, because the inability to create heterogenous collections just plain sucks. By the way, is there an AI for the second thing Ada could learn from Java, that is 'throws' clause? Regards, Wojtek