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 5AEE17ED26 for ; Thu, 7 Jun 2012 20:54:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmICAB/40E+AcIgmgWdsb2JhbABFo0yQXiIBARYmJ4IYAQEEAW4LBQsLJSFFEgYlh2sDBgULr0sDVIkEix2FLGADli+RZA X-IronPort-AV: E=Sophos;i="4.75,732,1330902000"; d="scan'208";a="146952414" Received: from bluebox.cs.princeton.edu ([128.112.136.38]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 07 Jun 2012 20:54:45 +0200 Received: from sslvpn-96-188.sei.cmu.edu (vpn-nat-159.sei.cmu.edu [128.237.27.159]) (authenticated bits=0) by bluebox.CS.Princeton.EDU (8.13.8/8.13.8) with ESMTP id q57IsdPR004555 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 7 Jun 2012 14:54:42 -0400 Mime-Version: 1.0 (Apple Message framework v1278) Content-Type: text/plain; charset=iso-8859-1 From: Yitzhak Mandelbaum In-Reply-To: Date: Thu, 7 Jun 2012 14:54:41 -0400 Cc: caml-list Content-Transfer-Encoding: quoted-printable Message-Id: References: To: =?iso-8859-1?Q?Daniel_B=FCnzli?= X-Mailer: Apple Mail (2.1278) Subject: Re: [Caml-list] Local functions with arguments or closures ? Daniel, I can't speak definitively, but in my experience, the cost of using a closu= re had a noticeable performance impact when writing loops as recursive func= tions.=20 Yitzhak On Jun 7, 2012, at 1:34 PM, Daniel B=FCnzli wrote: > Hello,=20 >=20 > In the past I remember having indirectly benchmarked two different styles= for writing local functions : >=20 > let f x =3D=20 > let v =3D ... in > let rec loop x v =3D ... in=20 > loop x v=20 >=20 > or=20 >=20 > let f x =3D=20 > let v =3D ... in > let rec loop () =3D ... (* uses v and x *) in=20 > loop () >=20 > without being able to reach a conclusion. Is there any particular style t= hat is definitively faster ? Does it maybe depend on the number of argument= s and/or on whether loop is recursive or not ?=20 >=20 > 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 prov= ide a more reasonable answer than benchmarks.=20=20 >=20 > Best, >=20 > Daniel >=20 >=20 >=20 >=20 >=20 > --=20 > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >=20 ----------------------------- Yitzhak Mandelbaum