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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-21 10:55:36 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline17@hotmail.com (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: 21 Jan 2003 10:55:36 -0800 Organization: http://groups.google.com/ Message-ID: References: <1042477504.547640@master.nyc.kbcfp.com> <1042651417.215661@master.nyc.kbcfp.com> <1042743579.1165@master.nyc.kbcfp.com> <1042824191.538184@master.nyc.kbcfp.com> <_VkW9.266404$FT6.43771824@news4.srv.hcvlny.cv.net> NNTP-Posting-Host: 192.76.54.20 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1043175336 26357 127.0.0.1 (21 Jan 2003 18:55:36 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 21 Jan 2003 18:55:36 GMT Xref: archiver1.google.com comp.lang.ada:33307 Date: 2003-01-21T18:55:36+00:00 List-Id: Dmitry A. Kazakov wrote in message news:... > On Tue, 21 Jan 2003 02:10:37 GMT, "Hillel Y. Sims" > wrote: > > >"Dmitry A. Kazakov" wrote in message > >news:b0e5vu$ognn6$1@ID-77047.news.dfncis.de... > >> Hillel Y. Sims wrote: > >> > [templated C++ sort() is faster than qsort()] > >> > >> This is a wrong comparison. A correct one would be an instance of a > generic > >> subroutine vs. an inlined subroutine and, note, when the type is > statically > >> known. > > > >sort() vs. sort_ints()? In that case the performance should really be > >exactly the same (since as you say, it really *is* to a large extent just a > >bunch of text substitution :-). The benefit is that you don't need to > >rewrite or copy/paste the code over and over for each unique type, the > >compiler does it automatically (while maintaining full type safety, unlike > >dumb macros) -- and better yet, when you fix a bug in the generic version, > >it is immediately fixed for all instantiations automatically (vs. > >sort_ints(), sort_floats(), sort_strings(), sort_xyz()) > > This is an advantage of generics over blind preprocessing. The problem > is whether same can be achieved without both. > > Consider class-wide sort written for all arrays derived from some > abstract array of comparable elements. If that sort is inlined, then > then compiler theoretically would have all necessary information to > make code as efficient as generic sort could. Presently it is > impossible in both Ada and C++. But then to be sortable the element type would have be derived from some "Comparable" base type. And to be stored in a hash table, they would have to be derived from a "Hashable" base type. And to be used with some generic mathematical algorithm they would have to be derived from an "Arithmetic" base type...