caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michael Ekstrand <michael@elehack.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Can this be inlined?
Date: Mon, 10 Jan 2011 15:31:39 -0600	[thread overview]
Message-ID: <4D2B7ABB.2080609@elehack.net> (raw)
In-Reply-To: <4D2B7893.5030802@mcmaster.ca>

On 01/10/2011 03:22 PM, Jacques Carette wrote:
> let rec trav f = function
>   | A -> A
>   | B (x,e) -> B (oapply f.a x, trav f e)
>   | C (x,e) -> C (oapply f.b x, trav f e)
>
> let t1 = {a=Some id; b=None}
>
> let tt x = trav t1 x
>
> I would like for 'tt' to contain a version of trav with no traces of
> either oapply or t1 left.  How can I achieve that?  Is it possible?  I
> don't mind changing idioms (modules instead of record, etc), as long
> as I can get my inlining to go through.  [I also tried making oapply
> and trav "local" to tt's definition, but that did not seem to make
> much of a difference].
>
> In any case, the real goal here is to see if I can safely adopt a
> coding style like this, or do I need to manually do all the inlining
> myself?

I think that the problem is in the definition of 'trav' - it is both
recursive and allocates memory.  AFAIK, the OCaml compiler (at least the
native code one) does not inline functions that are either recursive or
allocate memory.  So I think your only option - unless trav can be
drastically rewritten - is to inline them yourself.

- Michael

  reply	other threads:[~2011-01-10 21:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-10 21:22 Jacques Carette
2011-01-10 21:31 ` Michael Ekstrand [this message]
2011-01-11  8:52 ` Damien Doligez

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=4D2B7ABB.2080609@elehack.net \
    --to=michael@elehack.net \
    --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).