Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news00.sunet.se!sunic!news.sprintlink.net!newsfeed.internetmci.com!EU.net!Norway.EU.net!nntp.uio.no!NewsWatcher!user From: kolbjorn.aambo@ub.uio.no (Kolbjørn Aambø) Newsgroups: comp.lang.beta Subject: Re: Templates Date: 20 Oct 1995 12:33:32 GMT Organization: University of Oslo Library Lines: 67 Message-ID: References: NNTP-Posting-Host: ubmac86.uio.no In article , carroll@auriga.cis.udel.edu (Mark C. Chu-Carroll) wrote: > > Kolbjørn> C++'s tool for creating tempates seems like a powerful tool > Kolbjørn> to generate better libraries. > > Does it? I disagree. > > A template specifies an *untyped parameterized textual replacement* > which can be instantiated to generate real code. It's a *nasty* > mechanism. > > There's a number of problems with it. For details, ask anyone who's > tried using template code - most of us who've gone through that agony > have horror stories. The central problem is the fact that it's an > untyped mechanism in a strongly typed language - you end up getting > some incomprehensible type errors as a result of template > instantiations that generate type incorrect code. > > (What's particularly frustrating about that is the fact that it's > actually pretty easy to generate parameterized types and functions in > a strongly typed language. Just take a look at parameterized types and > functors in ML, generics in Ada, constrained parametric types in > Eiffel and Sather, parametric modules in Modula-3, or parameterized > clusters in CLU. They've all solved that problem.) > > Beta already has the ability to build various kinds of parametrics, by > using virtual patterns and pattern variables. And it's type safe and > sane. The way that you go about building the parametrics is rather > different, but then you do a *lot* of things differently in Beta. It > works well, and it fits quite elegantly into the language. > In the C++ Standard draft the STL part it is claimed that almost all Template related typechecking is *static*. Codegeneration is dependent on the types of the parameters given to the templates upond instansiation done during *Compiletime*. Compared to that BETA's virtual functions and attrivutes are per definition *DYNAMICALLY* CHECKED! Until now I have only seen C++ compilers with bad error messages related to wrongly inplemented templates but... That is possibly more caused by sloppy programming than sloppe language... Still I agree that BETA is more understandable and easier to remember... still not intuitively evident.... Have I misunderstood anything? ................................................................ Universitetsbiblioteket i Oslo/Bibliografisk avd. The University of Oslo library/Bibliographic dept. N-0242 Oslo, Norway Kolbj|rn H. Aamb| University Librarian Phone: +47 22 85 91 36 Fax: +47 22 85 90 50 E-mail: kolbjorn.aambo@ub.uio.no http://www.nbo.uio.no/html/nansen/nanseneng.html http://www.nbo.uio.no/html/krigstr/krigstr.html ................................................................ There is No Way like Norway ................................................................ Welcome to Virtual Relativity!