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 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-05 17:20:37 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!chi1.webusenet.com!c03.atl99!cyclone2.usenetserver.com!news.webusenet.com!news01.optonline.net!news4.srv.hcvlny.cv.net.POSTED!53ab2750!not-for-mail From: "Hillel Y. Sims" Newsgroups: comp.lang.ada References: <3E147D79.2070703@cogeco.ca> <4519e058.0301031434.51a0c880@posting.google.com> Subject: Re: Anybody in US using ADA ? One silly idea.. Organization: Phat Basset Novelties, www.phatbasset.com MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Mon, 06 Jan 2003 01:20:30 GMT NNTP-Posting-Host: 67.86.54.13 X-Trace: news4.srv.hcvlny.cv.net 1041816030 67.86.54.13 (Sun, 05 Jan 2003 20:20:30 EST) NNTP-Posting-Date: Sun, 05 Jan 2003 20:20:30 EST Xref: archiver1.google.com comp.lang.ada:32590 Date: 2003-01-06T01:20:30+00:00 List-Id: I can't really speak much for experience with generics in Ada, but since your original point was "Generics in any form is an illness of programming languages", let me try to address a few of your general issues w/r/t C++ templates at least.. "Dmitry A. Kazakov" wrote in message news:av9egl$dd34q$2@ID-77047.news.dfncis.de... > In short generics is a meta language and no more than dressed macros used to > patch the source code. They are much more than dressed macros; there is also a great deal of semantic context which is totally unavailable with macros. >More elaborated: > > 1. Generics are static. You cannot have an object or dynamic-link library of > generics. I have written and maintain a number of (large) dynamic-link libraries of instantiations of C++ templates. > > 1.a. This kills code reuse at run-time. This is therefore not necessarily true, based on the above. > > 1.b. You cannot have a true polymorphism with generics. [A fake, "static" > polymorphism was invented to hide the truth.] Depends on your definition of 'polymorphism'. I have done some interesting things with compile-time polymorphism (inheriting a class from a template base class of the derived type). Anyhow, I see compile-time static and run-time dynamic polymorphism as complementary techniques which can provide a greater amount of flexibility in combination than either alone. > > 1.c. You have geometric code size explosion if you consequently use > generics. I guess this depends on the instantiation model and a lot of other variables. It is not inherently true with C++ templates. > > 4. Generics are inconsistent with DbC. In C++ you just instantiate and pray. > In Ada it is better, but still you have reemergence of predefined > operations and other contract violations. The reason is clear, while the > core language operates with types and their relations, generics are sort > of: let's substitute one string for another and see if the result go > through the compiler. I think it was Kernigan and Ritchie who said that > preprocessor does not know C. Substitute generics for preprocessor and > language X for C. Sorry, I don't really follow this point at all. > > 5. Generics are unstructured and too powerful. They are comparable with > gotos. Gotos arbitrarely change control flow. Generics arbitrarely produce > new language objects. You can have a generic type, subroutine, package, > everything. The consequences of an instantiation is almost impossible to > predict. As with gotos, you should admit, that a program with generics is > very difficult to understand and maintain. [For C++ replace difficult to > impossible, because of automated instantiation] Again, I can't really speak of Ada generics, but I maintain several sizeable C++ libraries which make extensive use of templates. The amount of functionality provided is far greater with much fewer lines of code than the equivalent non-templated version would be. This complexity issue simply does not seem to be inherent in the manner in which you imply, at least with C++ templates. > 6. Generics completely fall out of the language, because in fact they form a > meta-langauge. A generic object does not exist for the core language. What > could be done with a generic object? The answer is: nothing. One cannot > pass a generic function as a parameter to a normal function. Even a generic > parameter cannot be generic (:-)), only instances [= objects of the core > language] are allowed. So even as a meta-language, generics represent an > inconsistent one. > The biggest research/growth area in C++ these days seems to be templates and meta-programming. It is true there are some inconsistencies in the meta-language, but they don't prevent a lot of interesting programming from being done. If you have never seen the Boost Meta-Programming Library (http://www.boost.org/libs/mpl/doc/), you might want to check it out briefly; it demonstrates that quite a great deal can be done at compile-time with uninstantiated generic meta-objects. Anyhow, I will acknowledge that there are issues which need to be addressed/understood for successful use of generics/templates, and some of your points may be more oriented toward Ada than any other language, but I remain fully unconvinced that true generics (not glorified macros) are inherently a bad idea in any particular programming language. hys -- (c) 2003 Hillel Y. Sims hsims AT factset.com