Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Juan Jose Garcia Ripoll <jjgarcia@ind-cr.uclm.es>
To: Caml list <caml-list@pauillac.inria.fr>
Subject: The way Ocaml inlines
Date: Thu, 14 Jan 1999 10:49:48 +0100	[thread overview]
Message-ID: <369DBDBC.EA1CBE02@ind-cr.uclm.es> (raw)
In-Reply-To: <001001be3f70$ec08a870$210148bf@dylan>

David McClain wrote:
> 
> >(particularly if you inline it).
> 
> Is there a way to explicitly inline functions, other than cut and paste?

By watching OCaml work, and studying the compiler, I've seen it inline
many small functions, even when they are defined in other modules. I
pretty much like this, but I find only one minor inconvenience about the
way OCaml inlines. It is this one: say that you have

	module Foo = struct
	let ap_succ f n = f (n +. 1.0)
	let test a =
	   let my_f x = cos x
	   in ap_succ my_f a
	end

After inlining, the result is not a sort of
	let test a = cos (n +. 1.0)
but something like
	let my_f x = cos x
	let test a = generic_apply my_f (a +. 1.0)
It is even worse if `my_f' uses, for instance, `a', because then a
closure is built, which would not be necessary. I think this could be
solved by making the `inliner' a bit smarter and re-inlining the
functions that are applied. This would make it attractive and efficient
to write small useful functions in separate modules.

Regards
	Juanjo

-- 
Juan Jose Garcia Ripoll		www: http://www.arrakis.es/~worm
Dpto. de Matematicas		job: jjgarcia@ind-cr.uclm.es
E.T.S.I. Industriales		home: worm@arrakis.es
Univ. de Castilla-La Mancha, Ciudad Real E-13071 (Spain)




      reply	other threads:[~1999-01-14 23:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-14  3:49 Map is not tail recursive David McClain
1999-01-14  9:49 ` Juan Jose Garcia Ripoll [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=369DBDBC.EA1CBE02@ind-cr.uclm.es \
    --to=jjgarcia@ind-cr.uclm.es \
    --cc=caml-list@pauillac.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