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.1 required=5.0 tests=BAYES_20,INVALID_DATE, MSGID_SHORT autolearn=no autolearn_force=no version=3.4.4 Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!rutgers!mcnc!rti!jb From: jb@rti.UUCP (Jeff Bartlett) Newsgroups: comp.lang.ada,comp.lang.c Subject: Re: "C" vrs ADA Message-ID: <1678@rti.UUCP> Date: Thu, 27-Aug-87 13:44:37 EDT Article-I.D.: rti.1678 Posted: Thu Aug 27 13:44:37 1987 Date-Received: Sat, 29-Aug-87 10:01:47 EDT References: <1065@vu-vlsi.UUCP> <2231@cbmvax.UUCP> <36@sarin.UUCP> <1937@sfsup.UUCP> Distribution: na Organization: Research Triangle Institute, RTP, NC Summary: Illustrate a generic merge sort package that handles both fixed and floating types. Xref: mnetor comp.lang.ada:588 comp.lang.c:3967 List-Id: In article <1937@sfsup.UUCP>, mpl@sfsup.UUCP (M.P.Lindner) writes: > [ the following are excerpts - see the original articles for context ] > > ...... I do take exception, however to the statements that > Ada is an "object oriented" language. Yes, it is, but it was implemented > no better than that of C++. Example: Try to make a generic merge sort > which can sort floats and integers. Unless this has been fixed since I > learned Ada, it can't be done! The reason I was given is a generic type > can only assume assignment and equality. If we add constraints, we must > specify either integral types or floating types. Little inconsistancies > make life hell for programmers, as well as conflicting with the stated intent > of the methodology. > > Mike Lindner > attunix!mpl What about ...... generic type ITEM is private; with function GREATER(A,B : ITEM) return BOOLEAN is <>; package SORTING is type VECTOR is array(NATURAL range <>) of ITEM; procedure MERGE_SORT( A, B : VECTOR; RESULTS : out VECTOR ); end SORTING; This generic package can be instatiated for fixed, floating and record types. Jeff Bartlett Center for Digital Systems Research Research Triangle Institute jb@rti.rti.org