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 QAA28894; Sun, 2 May 2004 16:12:52 +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 QAA28767 for ; Sun, 2 May 2004 16:12:51 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i42ECmSH004092 for ; Sun, 2 May 2004 16:12:50 +0200 Received: from [192.168.1.200] (ppp116-155.lns1.syd2.internode.on.net [150.101.116.155]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i42ECgk2070811; Sun, 2 May 2004 23:42:44 +0930 (CST) Subject: Re: [Caml-list] Functors From: skaller Reply-To: skaller@users.sourceforge.net To: Jon Harrop Cc: caml-list In-Reply-To: <200405021434.22102.jdh30@cam.ac.uk> References: <200405021434.22102.jdh30@cam.ac.uk> Content-Type: text/plain Message-Id: <1083507162.20722.351.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 03 May 2004 00:12:42 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 409501E0.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 functors:01 sourceforge:01 2004:99 2004:99 functors:01 functor:01 lri:01 signoles:01 ocamldefun:01 ocamldefun:01 inlining:01 instantiate:01 functor:01 9660:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Sun, 2004-05-02 at 23:34, Jon Harrop wrote: > On Sunday 02 May 2004 11:24, Martin Jambon wrote: > > On Sun, 2 May 2004, Jon Harrop wrote: > > > Functors appear to be somewhat similar to templates in C++. Does the > > > functor approach produce more efficient code as it is partially > > > specialised over the comparison function? > > > > Unfortunately no. > > ... > > http://www.lri.fr/~signoles/ocamldefun/manual.html > > Wow, ok. So ocamldefun maps ocaml code with functors onto ocaml code without > functors and, according to their examples, this can result in an 8 times > performance improvement due to inlining. > > This begs the question: why is this functionality not in the compiler? In > fact, using functors with the current compiler actually reduces > performance... The answer is separate compilation. When you instantiate a Set.Make .. you only have the interface. Hard to inline without actually having the body of the functor.. -- 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