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,c0d427d5f4af20f8 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!g47g2000cwa.googlegroups.com!not-for-mail From: "Hyman Rosen" Newsgroups: comp.lang.ada Subject: Re: generics in Ada 83 Date: 14 Sep 2005 06:15:15 -0700 Organization: http://groups.google.com Message-ID: <1126703715.202970.293880@g47g2000cwa.googlegroups.com> References: <1126617980.932226.320710@g43g2000cwa.googlegroups.com> NNTP-Posting-Host: 204.253.248.208 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1126703721 17929 127.0.0.1 (14 Sep 2005 13:15:21 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 14 Sep 2005 13:15:21 +0000 (UTC) User-Agent: G2/0.2 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.10) Gecko/20050716 (No IDN) Firefox/1.0.6,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: g47g2000cwa.googlegroups.com; posting-host=204.253.248.208; posting-account=lJDDWg0AAACmMd7wLM4osx8JUCDw_C_j Xref: g2news1.google.com comp.lang.ada:4657 Date: 2005-09-14T06:15:15-07:00 List-Id: Jean-Pierre Rosen wrote: > The benefit is that if a generic compiles, and the instantiation > provides parameters that match the contract (of the generic formals), > then the instantion is *always* OK. How is that different from templates? If the template compiles, and the instantiation provides parameters such that all usage within the template is legal, then the instantiation is OK. Otherwise the program doesn't compile. Ada has explicit contracts and C++ does "contract by usage" but in either language, once the program compiles it is correct. Supplying contracts in C++ would be vastly more difficult than it is in Ada, because C++ has a variety of automatic conversions and because C++ templates can be specialized whereas Ada generics cannot be.