From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by sympa.inria.fr (Postfix) with ESMTPS id 095B67ED26 for ; Thu, 7 Jun 2012 19:34:58 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtABAGDl0E9KN1ZKnGdsb2JhbABFhU6udQEBAQEBCAsJCRQngkKBCwImAkkWG4gDBJdujj6SaIEjjnQyYAOaXRONCQ X-IronPort-AV: E=Sophos;i="4.75,732,1330902000"; d="scan'208";a="146947420" Received: from mail6.webfaction.com (HELO smtp.webfaction.com) ([74.55.86.74]) by mail4-smtp-sop.national.inria.fr with ESMTP; 07 Jun 2012 19:34:57 +0200 Received: from [192.168.0.101] (121-233.197-178.cust.bluewin.ch [178.197.233.121]) by smtp.webfaction.com (Postfix) with ESMTP id EABF621078E6 for ; Thu, 7 Jun 2012 12:34:54 -0500 (CDT) Date: Thu, 7 Jun 2012 19:34:49 +0200 From: =?utf-8?Q?Daniel_B=C3=BCnzli?= To: caml-list Message-ID: X-Mailer: sparrow 1.6.1 (build 1081.52) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: [Caml-list] Local functions with arguments or closures ? Hello, In the past I remember having indirectly benchmarked two different styles for writing local functions : let f x = let v = ... in let rec loop x v = ... in loop x v or let f x = let v = ... in let rec loop () = ... (* uses v and x *) in loop () without being able to reach a conclusion. Is there any particular style that is definitively faster ? Does it maybe depend on the number of arguments and/or on whether loop is recursive or not ? This question keeps coming back in my mind when I write local functions... I'm sure someone with some knowledge of the compiler's internals can provide a more reasonable answer than benchmarks. Best, Daniel