From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id CAA18151; Fri, 18 Oct 2002 02:57:51 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA18192 for ; Fri, 18 Oct 2002 02:57:50 +0200 (MET DST) Received: from boule.etirade.com (12-247-44-244.client.attbi.com [12.247.44.244]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g9I0vnD25830 for ; Fri, 18 Oct 2002 02:57:49 +0200 (MET DST) Received: (qmail 1143 invoked from network); 18 Oct 2002 00:57:48 -0000 Received: from unknown (HELO batard.etirade.com) (192.168.1.34) by boule.etirade.com with SMTP; 18 Oct 2002 00:57:48 -0000 Content-Type: text/plain; charset="iso-8859-1" From: Jeffrey Palmer To: Alessandro Baretta , Ocaml Subject: Re: [Caml-list] Re: Camlp4 optimizations (was: productivity improvement) Date: Thu, 17 Oct 2002 19:57:28 -0500 User-Agent: KMail/1.4.3 References: <200210171637.15448.jeffrey.palmer@acm.org> <3DAF4DF8.707@baretta.com> In-Reply-To: <3DAF4DF8.707@baretta.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200210171957.28279.jeffrey.palmer@acm.org> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thursday 17 October 2002 6:55 pm, Alessandro Baretta wrote: > I'm sorry to have to point out that this is false. The > template rewriting mechanism knows absolutely nothing about > typing. You can give the C++ compiler a template it will > placidly accept, while at the same time giving you all sorts > or typing errors at template instantiation time. This means > that if you write a template library in C++ you'll know if > it is type-correct (with respect to C++ *very weak* typing > rules) only when you try to use it in some other project. > This is equivalent to the non-typing of assembly language, > which yields all sorts of runtime errors to the users. As > far as C++ templates go, you have to consider as users the > programmers who will use the template library. Template > instantiation plays the part of running an assembled program. > Hmm. I have two observations: 1) You can't "use" templates without instantiating them, so although=20 you're right - template type checking is deferred to instantiation,=20 this is by design (a pain, I agree). 2) Template code, during instantiation, has access to the type system.=20 You can write conditional template code that will be instantiated only=20 if A is a subclass of B, etc. Although the mechanisms used to do this=20 are obtuse, it is possible. > The golden rule of C++: Use classes, not templates. Interesting. I'd say the opinion has shifted from not using templates to=20 using them for almost everything. It seems that, since the introduction=20 of the C++ standard library, everyone is building template libraries.=20 It's almost as though people have decided that "virtual" is a dirty=20 word. ;) > Once Camlp4 has built the syntax > tree you can apply any program transformation you care to, > in order to optimize your program. I really have to make some time to play with that thing - it really=20 sounds amazing. Oh, and in response to my own earlier question regarding partial=20 evaluation and strongly-typed languages, I noticed a post elsewhere on=20 the list to a very interesting site: http://www.cs.rice.edu/~taha/MetaOCaml/ Enjoy! =09- j --=20 The river is moving. The blackbird must be flying. ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners