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 DAA23438; Tue, 28 Sep 2004 03:21:59 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA24319 for ; Tue, 28 Sep 2004 03:21:58 +0200 (MET DST) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id i8S1LtAl003076 for ; Tue, 28 Sep 2004 03:21:57 +0200 Received: from [192.168.1.200] (ppp202-133.lns1.syd3.internode.on.net [203.122.202.133]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i8S1Li4Y091712; Tue, 28 Sep 2004 10:51:49 +0930 (CST) Subject: Re: [Caml-list] C++ STL and template features compared with OCaml parametric polymorphism and OO features From: skaller Reply-To: skaller@users.sourceforge.net To: Brian Hurt Cc: caml-list In-Reply-To: References: Content-Type: text/plain Message-Id: <1096334498.28613.771.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 28 Sep 2004 11:21:41 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 4158BCB3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 bloat:01 demonstrate:01 val:01 ,1.0:01 endl:01 stdout:01 endl:01 bloat:01 optimiser:01 9660:01 glebe:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 2004-09-28 at 03:01, Brian Hurt wrote: > On 28 Sep 2004, skaller wrote: > > > Yes, because it costs nothing, which is much cheaper > > than the virtual dispatch: > > This is wrong. It does cost something- it costs code bloat, because now > instead of a single copy of the comprehension, you have a whole bunch of > copies, one for each time you call the comprehension. I can't demonstrate easily for g++, but can do so easily for Felix, which uses the same mechanism. First the input: -------------------------- include "std"; fun apply[T] (f:T->T,a:T):T => f a; val x = apply(sin of (double),1.0); print x; endl; ------------------------- and here is the code generated by 'flx --inline' //x := (Double::sin 1.0); ptf->_i1549_v1533_x = (sin((1.0))); // primcall Double::print x; {std::cout<<(ptf->_i1549_v1533_x);} // primcall Stdout::endl (); {std::cout << endl;} What you claim may be true in general: extensionl polymorphism costs in terms of code bloat, and sometimes that leads to a performance cost. It will be fun to measure that when the Felix optimiser is working well enough to compare it with ocaml. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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