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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c1fe4bc1dd51fc87 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s8g2000prg.googlegroups.com!not-for-mail From: Eric Hughes Newsgroups: comp.lang.ada Subject: Re: User-defined type attributes (replacing genericity) Date: Fri, 14 Mar 2008 10:51:25 -0700 (PDT) Organization: http://groups.google.com Message-ID: <821256cd-2d20-46dd-92d2-cdd21181dbb8@s8g2000prg.googlegroups.com> References: <30f629fd-69d3-4d40-995f-9933f52b8dad@s37g2000prg.googlegroups.com> <965suhjl0bxt$.74se2ylyksin.dlg@40tude.net> <1205505100.6445.60.camel@K72> NNTP-Posting-Host: 166.70.57.218 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1205517085 13676 127.0.0.1 (14 Mar 2008 17:51:25 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 14 Mar 2008 17:51:25 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s8g2000prg.googlegroups.com; posting-host=166.70.57.218; posting-account=5RIiTwoAAACt_Eu87gmPAJMoMTeMz-rn User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20384 Date: 2008-03-14T10:51:25-07:00 List-Id: On Fri, 14 Mar 2008 15:31:40 +0100, Georg Bauhaus wrote: > Without generics, there is only one Is_Highest, as might be > expected. On Mar 14, 8:48 am, "Dmitry A. Kazakov" wrote: > Why there have to be two? The whole idea of generics was to have *one* > generic body. This is why it is called generic [programming]. Here's the nut of the problem. There is one generic body in the code of the programming language. When you substitute type parameters into that generic body, you get multiple different manifestations of that original generic body, that is, multiple bodies, one for each type. And that means multiple versions as translated into machine code. This is indeed the primary desideratum of generic programming. Having said this, there's a standard technique of converting type operations into virtual function calls. I feel like I need to say this--these aren't the same thing. This allows the reduction of the manifestation a generic body to a single canonical form. This has a single version in machine code. A realistic system for generic programming should support both modes of code generation. This allows the developer to determine their own answer to the code-size vs. performance trade-off. Ada has already taken the stance, as evidenced by representation clauses, that it will support both high and low levels of abstraction. Eliminating generics would force everything into virtual function calls, choose code-size over performance, and make that choice on behalf of every programmer. If you go down the road of requiring all method calls to be virtual, of requiring that there be run-time manifestations of all meta- language features, you get Java. Java has its place. So does Ada. These aren't the same place. Eric