From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA11385 for caml-redistribution; Fri, 15 Jan 1999 00:11:40 +0100 (MET) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA13804 for ; Thu, 14 Jan 1999 10:53:05 +0100 (MET) Received: from alarcos.uclm.es (alarcos.uclm.es [161.67.26.25]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id KAA29508 for ; Thu, 14 Jan 1999 10:53:04 +0100 (MET) Received: from ind-cr.uclm.es (IDENT:jjgarcia@[161.67.37.202]) by alarcos.uclm.es (8.9.0/8.9.0) with ESMTP id KAA12553 for ; Thu, 14 Jan 1999 10:53:03 +0100 Sender: weis Message-ID: <369DBDBC.EA1CBE02@ind-cr.uclm.es> Date: Thu, 14 Jan 1999 10:49:48 +0100 From: Juan Jose Garcia Ripoll Organization: Universidad de Castilla-La Mancha X-Mailer: Mozilla 4.07 [en] (X11; I; Linux 2.0.36 i686) MIME-Version: 1.0 To: Caml list Subject: The way Ocaml inlines References: <001001be3f70$ec08a870$210148bf@dylan> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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)