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,FREEMAIL_FROM autolearn=ham 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!postnews.google.com!k13g2000hse.googlegroups.com!not-for-mail From: Ivan Levashew Newsgroups: comp.lang.ada Subject: Re: Interfaces and abstract tagged types Date: Wed, 22 Oct 2008 23:39:10 -0700 (PDT) Organization: http://groups.google.com Message-ID: <4ba8b27d-6228-4451-bfc6-ef19dd4b96cb@k13g2000hse.googlegroups.com> References: <1w8x4i0peinwk$.16cenhvch5kv5.dlg@40tude.net> <6a44b25e-07c7-4b3f-9e22-08a778073e4a@q26g2000prq.googlegroups.com> <48f716fc$0$28911$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 92.125.96.125 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1224743951 9451 127.0.0.1 (23 Oct 2008 06:39:11 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 23 Oct 2008 06:39:11 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k13g2000hse.googlegroups.com; posting-host=92.125.96.125; posting-account=SWSr0goAAABcqpu6T_j1x1_Ub5y2Ekfy User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2471 Date: 2008-10-22T23:39:10-07:00 List-Id: > For the JNI and similar? Unlikely. CORBA mapping works fine without interfaces. Some notes on the subject itself: Usually, interfaces should be preferred. But sometimes there are cases where different objects must closely interact, and they explicitly must have a common internal represenation. Consider 2 examples: 1. You have a set of objects. This set is internally sorted somehow. You'd like to have a "&"(Left, Right : Set_Type) operation. Although it's pretty possible to compose an universal merge implementation being able to inefficiently merge vendor A's set and vendor B's set, one would like to use efficient merges. In this case, Left and Right must have something in common, that is, be an descendants of abstract tagged type instead of interface. 2. Another case is sockets. There is a "select()" procedure in Sockets API. Let's assume that there are several finite state machines operating on sockets streams. Vendor A's FSM and vector B's FSM must have a common internals in order to be able to be used in a "select()" call. Once again, abstract tagged type is preferred over interface here. There's a bad option to define "anti-interface" exposing desired internals, e. g. socket handle. Don't do like this. --------------------- > The perversion is that inheritance as form of polymorphism is > technically > replaced by another form of (parametric polymorphism). What are > interfaces for, if generics must be used instead? Interfaces are for run-time polymorphism, the final goal. Generics is just an aid to do it in a handy way. > In order to handle this exponentially exploding code, > generics are > introduced down the tree. I.e. Bi becomes a generic and > interfaces are > passed as formal parameters of. Then the generic instances > are passed down > the tree to lower generics. Right, it is supposed to be used this way. Maybe your complaints are due to lack of good UML tools for Ada 2005? > The interface > cannot be inherited from a concrete type I think this is obvious that Ada designer can't let you do this trick. A concrete type might have more primitive operation than interface you're want to declare. List and Vector have extra operations that can be done efficiently. How can Ada compiler be sure whether you'd like to treat Vector implementation as an implementation of hypothethic Vector_Interface or whether Vector is just an enumerable container. If it's really the case that every primitive operation must be copied to the interface, this fact must be stated explicitly.