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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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-19 04:34:09 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!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!dialin-145-254-037-164.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. Date: Sun, 19 Jan 2003 13:34:36 +0100 Organization: At home Message-ID: References: <1041908422.928308@master.nyc.kbcfp.com> <1041997309.165001@master.nyc.kbcfp.com> <1042086217.253468@master.nyc.kbcfp.com> <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> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-037-164.arcor-ip.net (145.254.37.164) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1042979647 25714406 145.254.37.164 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:33202 Date: 2003-01-19T13:34:36+01:00 List-Id: Hillel Y. Sims wrote: > "Dmitry A. Kazakov" wrote in message > news:b0bhef$ni0jk$1@ID-77047.news.dfncis.de... >> If they are better, then there should be a rationale for that. So far, > there >> are only two arguments: >> >> 1. Efficiency [which is arguable and very often not an issue in a large >> system] > > Are you serious? Just a small example of potential efficiency, C++ > templated std::sort() function is proven to be non-trivially faster than > the mostly-equivalent C-based non-templated std::qsort() function which > uses untyped void* parameters. On my system (HP Alphas running OpenVMS), > templated std::sort() is more than 60% faster than std::qsort() for arrays > of 500,000 integers or floats. Recent profiling of our system (financial > data integration/analysis) indicated some sorting routines (really old > fortran-based code) as potential relevant targets for efficiency > improvement. I imagine similar kinds of efficiency improvement are > possible in Ada using generics vs. untyped code? 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. >> 2. They can something, that other gears cannot [what if they could?] > > Has anyone suggested anything better yet? Yes. type X is array (Integer range <>) of Y; is definitely better than a generic version with the array size as the parameter. type X (Param : Y) is ...; is also almost always better than generics. >> Compare this with gotos. They are extremely efficient and they do can > [make >> a maintenance nightmare out of any program] > > How do you compare gotos to generics? Generics do not destroy structured > code. I just don't understand the analogy. They are as chaotic as gotos. They destroy the type structure of the program as gotos do the control flow. Hyman Rosen gave us a brilliant example of generic code for handling dimensioned values. But get a programmer from street and ask him why and how it works. Programming should be as simple as tooth powder. (:-)) >> This changes nothing: >> >> template class Y ...; >> >> how a specialization could help to create a container for Y. Note missing > <> >> after Y. There is simply no such thing as Y. There is only a bunch of >> instances of Y, which are absolutely *unrelated*! > > It can actually help. For example, in the case of the standard C++ > container class std::vector -- there can be a specialization defined (I > forget if it is mandated by the Standard, but it is possible anyhow) for > all std::vector such that they are inherited from std::vector > with just the necessary casts thrown in by the compiler (inline). This can > eliminate a large amount of unnecessary code bloat for all instantiations > of vectors of pointer types. With pointer types we do not need generics at all, because all pointers are of some predictable size. Then it is not the actual problem. The problem is that std::vector is not a type, so even std::vector* cannot exist. -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de