caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Goswin von Brederlow <goswin-v-b@web.de>
To: Daniel Buenzli <daniel.buenzli@erratique.ch>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Local functions with arguments or closures ?
Date: Sun, 17 Jun 2012 01:14:48 +0200	[thread overview]
Message-ID: <87vciqj1cn.fsf@frosties.localnet> (raw)
In-Reply-To: <CE0EBC4C252E4B178BD00227099BA4D4@erratique.ch> ("Daniel Buenzli"'s message of "Thu, 7 Jun 2012 19:34:49 +0200")

Daniel Bünzli <daniel.buenzli@erratique.ch> writes:

> 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

Closure arguments prevent what little optimization there is in ocaml. So
better avoid them where time counts. But your example doesn't have any
closure arguments.

MfG
        Goswin

      parent reply	other threads:[~2012-06-16 23:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-07 17:34 Daniel Bünzli
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 [this message]

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=87vciqj1cn.fsf@frosties.localnet \
    --to=goswin-v-b@web.de \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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).