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,c9629eba26884d78 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-08-06 01:58:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.nacamar.de!fu-berlin.de!uni-berlin.de!tar-alcarin.cbb-automation.DE!not-for-mail From: Dmitry A. Kazakov Newsgroups: comp.lang.ada Subject: Re: XML DOM Binding for Ada 95 - matter of style Date: Wed, 06 Aug 2003 11:03:22 +0200 Message-ID: References: <3F28F61D.4050504@noplace.com> <3F2A5303.6080902@noplace.com> <3F2BA9C8.9030700@noplace.com> NNTP-Posting-Host: tar-alcarin.cbb-automation.de (212.79.194.111) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1060160290 28520907 212.79.194.111 (16 [77047]) X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:41217 Date: 2003-08-06T11:03:22+02:00 List-Id: On Tue, 5 Aug 2003 13:34:09 +0000 (UTC), Georg Bauhaus wrote: >Dmitry A. Kazakov wrote: >: Isn't signature just another word for interface? Does not a set of >: subroutines with compatible signatures constitute an interface for >: some abstract/real type? One could long for a better way to describe >: and manage interfaces, but there is no real alternative to them. > >You don't need to know about them during the design process, Really? >but you can construct "signature instances" like so: > >generic > type X is private; > function count(thing: X) return Natural; > procedure stretch(thing: in out X); >... > >and then instantiate "..." with whatever actuals seem fit. >This doesn't require that the provider of the units from which >X, count, etc. are taken, has to know beforehand that his/her types, >functions, or whatever will be used this way. It is an illusion of freedom. In fact, from the specification above, it is clear that X is private, i.e. has a default constructor, a copy constructor, an assignment, count, stretch. So it is pretty much said about possible X, and it is in fact an *interface*. Then when you instantiate, the actual type is checked against that interface. Now, how it differs from interface inheritance, except from techical details? It does not. Keep in mind, that present implementations of inheritance are very limited in many aspects. You cannot create supertypes, disallow methods, have by-value semantics, have multiple dispatch etc. I do not argue that things like STL can be implemented without templates. What I am saying is that it will be possible in the future with advantages of being: - safer - clearer - far more checkable - as efficient as macros in static cases - working in dynamic cases (with some bounded memory/time penalty) >Actually, you can pass operations of a tagged type as actuals. Yes, this is a great disadvantage of generics. You have to explicitly specify everything you need. Compare it with inheritance, you just specify a base type. This is because Ada's generics try to pretend to have some contract. C++ does not, it openly says that what you become is your own business. BTW, C++ is consistent in its approach: int Something; // Maybe it has enough range to keep our values, launch and enjoy! template void Sort ...; // Guess, what I have used here this week, "<=" or ">="? >Can this be done with virtual member functions in C++? You mean to pass a dispatching operation to a template? --- Regards, Dmitry Kazakov www.dmitry-kazakov.de