Section: New Results
The Objective Caml system and extensions
The Objective Caml system
Participants : Damien Doligez, Xavier Leroy, Michel Mauny, Nicolas Pouillard, Pascal Cuoq [ CEA ] , Alain Frisch [ Lexifi ] , Jacques Garrigue [ University of Nagoya ] , Maxence Guesdon [ team SED ] , Luc Maranget [ project Moscova ] , Pierre Weis [ project Estime ] .
This year, we released versions 3.10.1, 3.10.2 and 3.11.0 of the Objective Caml system. Damien Doligez acted as release manager for these three versions.
Versions 3.10.1, released in January 2008, and 3.10.2, released in March 2008, are minor releases that correct about 85 problem reports. In addition, Damien Doligez and Pascal Cuoq enhanced the performance of weak pointers in the run-time system. The problems with weak pointers, Doligez and Cuoq's solution, and applications to weak hash tables were presented in a paper published at the ACM Workshop on ML  .
Version 3.11.0, released in December 2008, is a major release that brings the following improvements:
Support for dynamic loading of natively-compiled Caml code (Alain Frisch).
Addition of lazy patterns of the form lazy p , matching suspended computations whose values, after forcing, match the pattern p (Michel Mauny).
Extensions of private type declarations and of type coercions (Jacques Garrigue, Pierre Weis).
Improvements in memory management to reduce fragmentation and better support 64-bit platforms (Damien Doligez, Xavier Leroy).
Generation of 64-bit code for the Mac OS X / Intel platform (Xavier Leroy).
Software migration from reFLect to OCaml
Since september 2005 and with support from Intel, Michel Mauny, Nicolas Pouillard and Virgile Prevosto developed an implementation of the reFLect functional language designed and used at Intel. This implementation reuses the back-end of the OCaml compiler. At the end of 2007, Intel decided to progressively translate their reFLect code base to OCaml.
In 2008, Michel Mauny and Nicolas Pouillard developed a translator from reFLect to OCaml, based on the CaFL front-end for parsing and type-checking of source programs, a CamlP4-based translator of CaFL abstract syntax trees to OCaml syntax, and a post-processor that makes explicit lazy evaluation by inserting lazy and force instructions at the appropriate places. The main technical challenges are the automatic generation of OCaml bindings for the thousands of reFLect primitives, and the efficiency and practicality of the “lazy” OCaml library.
Software migration may need to be progressive, especially when the code base to be translated is big. In such situations, we may want to translate only parts of the original applications, linking two runtime systems into one, and using functionalities of the old system as primitives in the new one, in a typed way. Michel Mauny and Nicolas Pouillard designed a mechanism that allows the automatic import/export of functions and data structures between two languages. Based on a few low-level primitives for each data type, the transfer of values of a data type proceeds by automatically translating the values from one runtime to another: marshalling when the target language provides an implementation for the data, coercing to an abstract data type otherwise. This mechanism has been implemented by Nicolas Pouillard for the reFLect to OCaml translator, and its formal properties are still under investigation.
To implement the lazy semantics of the reFLect language, the reFLect to OCaml translator mechanically generates delays and force operations in OCaml. On the one hand, as it is generally the case in generated programs, many of the delays can be optimized away, when the evaluation to be delayed is trivial. Michel Mauny modified the Objective Caml compiler for those situations to be detected. On the other hand, the encoding of lazy evaluation on a realistic language with algebraic data structures and pattern-matching involves a tight interaction between matching (control and bindings) and forcing the evaluation of components of the values being matched. In order to make simpler this interaction, Michel Mauny extended the OCaml notion of pattern with so-called “lazy patterns” which integrate forced evaluation of lazy values inside pattern-matching, and extended the compilation of pattern-matching accordingly.