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-07 05:52:45 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!not-for-mail From: "Matthew Heaney" Newsgroups: comp.lang.ada References: <3F28F61D.4050504@noplace.com> <3F2A5303.6080902@noplace.com> <3F2BA9C8.9030700@noplace.com> Subject: Re: XML DOM Binding for Ada 95 - matter of style X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: Date: Thu, 07 Aug 2003 12:52:44 GMT NNTP-Posting-Host: 65.110.133.134 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1060260764 65.110.133.134 (Thu, 07 Aug 2003 05:52:44 PDT) NNTP-Posting-Date: Thu, 07 Aug 2003 05:52:44 PDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:41230 Date: 2003-08-07T12:52:44+00:00 List-Id: "Dmitry A. Kazakov" wrote in message news:egd1jvc6pe888e4ug683tis6a5q5ua12ml@4ax.com... > On Tue, 5 Aug 2003 13:34:09 +0000 (UTC), Georg Bauhaus > wrote: > > >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. This is a feature, not a flaw. The Ada generics were deliberately designed this way, because you get better error checking. > Compare it with inheritance, you just > specify a base type. This is because Ada's generics try to pretend to > have some contract. I don't know what you mean by "pretend" to have a contract: Ada generics do have a contract. In fact it's called the "generic contract model." > C++ does not, it openly says that what you become > is your own business. Well, yes and no. You don't just design ex nihilo, but with the expection that the generic actual type will have a specific set of operations, even if those operations are only loosely specified. > template void Sort ...; > // Guess, what I have used here this week, "<=" or ">="? No. Sort will only use operator<. It will never use operator<= or operator>=, because those can be derived from the canonical operator<. You should always define relational operators in terms of the less-than operatior: function "<" (L, R : T) return Boolean is ...; function ">" (L, R : T) return Boolean is begin return R < L; end; function ">=" (L, R : T) return Boolean is begin return not (L < R); end; function ">=" (L, R : T) return Boolean is begin return R <= L; end; In the STL and in Charles, you even use the less-then operator for computing "equivalence" of keys: function Is_Equivalent (L, R : T) return Boolean is begin return not (L < R) and not (R < L); end; The equality operator "=" for elements is only used to compute the value of container equality. > >Can this be done with virtual member functions in C++? > > You mean to pass a dispatching operation to a template? I showed how to do this in Ada in a previous post.