Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
OCaml defunctorization and other optimizations
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Török_Edwin <edwintorok@g...>
Subject: OCaml defunctorization and other optimizations

I've seen in several places recommendations to use 'ocamldefun' to speed
up OCaml programs that use functors heavily [*].

I was able to find the sources via the wayback machine.
Unsurprisingly it doesn't build with OCaml 3.11.2 (it wants OCaml 3.06).
Is there a more up to date variant of ocamldefun? Would it be possible
to port it to 3.11.2?

Is it possible to implement ocamldefun-like functionality via Camlp4's
AST filters?

Also is it possible to implement function specialization
(monomorphization?) using an AST filter?
The example from the OCaml tutorial is not optimized by

Or is it possible to get access to the OCaml compiler's IL
representation and make optimizations on that?

[*] For example when extracting ML programs from Coq using OCaml's
native 'int' type I get code like this (which is not inlined/optimized
at all by OCaml):
module Z_as_Int =
  let _2 = 2
  let mult = ( * )
module F =
 functor (I:Int) ->
  (** val mul2 : -> **)

  let mul2 n =
    I.mult I._2 n
module F2 = F(Z_as_Int)

Best regards,