caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Daniel Bünzli" <daniel.buenzli@erratique.ch>
To: caml-list <caml-list@inria.fr>
Subject: [Caml-list] Local functions with arguments or closures ?
Date: Thu, 7 Jun 2012 19:34:49 +0200	[thread overview]
Message-ID: <CE0EBC4C252E4B178BD00227099BA4D4@erratique.ch> (raw)

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





             reply	other threads:[~2012-06-07 17:34 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07 17:34 Daniel Bünzli [this message]
2012-06-07 18:54 ` Yitzhak Mandelbaum
2012-06-07 19:07 ` Gabriel Scherer
2012-06-07 20:09   ` AW: " Gerd Stolpmann
2012-06-07 22:10     ` Alain Coste
2012-06-07 23:45 ` Ville-Pertti Keinonen
2012-06-16 23:14 ` Goswin von Brederlow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CE0EBC4C252E4B178BD00227099BA4D4@erratique.ch \
    --to=daniel.buenzli@erratique.ch \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).