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-Thread: 103376,a84eaf8fb2470909 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news1.google.com!news.germany.com!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada generics Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1166710494.869393.108730@a3g2000cwd.googlegroups.com> Date: Thu, 21 Dec 2006 16:42:07 +0100 Message-ID: <17fe4xfogg7p5.1dcyc5nyc2gsl.dlg@40tude.net> NNTP-Posting-Date: 21 Dec 2006 16:41:56 CET NNTP-Posting-Host: 1ed1522d.newsspool1.arcor-online.net X-Trace: DXC==b5bjf4Fo<]lROoR1^YC2XCjHcb9C[MFWR]hO82DNcfSJ;bb[5IRnRBaCdkbkAIa57jn6Q=T4]ZEj8P4 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7973 Date: 2006-12-21T16:41:56+01:00 List-Id: On 21 Dec 2006 06:14:54 -0800, markww wrote: > I'm trying to compare generics in Ada vs C++ templates and Java > generics. Is there anything Ada generics can do that C++ or Java > cannot? I read that the Ada system was safer than C++ templates. I'm > just looking for some distinctive features. I cannot tell anything for Java, but Ada generics as compared with templates are "more": 1. Contract-based (this is the most important feature) 2. Support separate compilation (1 is a premise to have this) 3. Generic object parameters can have any type (in C++ you cannot use float, for example) 4. Generic object parameters can be mutable (in C++ only constants are allowed) 5. Generic type parameters can be limited to a class of types, like any integer type, or any type derived for some base, or any array type of elements etc. In C++ matching is untyped. 6. Generic instance parameters. You can pass an instance as a parameter. 7. Generic packages (~namespaces). Anything you put in gets parametrized by the formal parameters and instantiated upon the package instantiation. 8. Keyed association of generic parameters 9. Defaults for generic parameters 10. Nested generics and generic children (I don't list what is less than in C++, because you didn't ask for it. (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de