English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
(Announce) "OCAPIC" : OCaml for PIC18 microcontrollers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2010-11-11 (11:57)
From: Philippe Wang <philippe.wang@l...>
Subject: Re: [Caml-list] ocamlclean : an OCaml bytecode cleaner (Was: (Announce) "OCAPIC" : OCaml for PIC18 microcontrollers)

ocamlclean removes code to which there is no possible path. For instance, this program :
  let plop = List.map succ [1;2;3];;
uses module List (for map) and module Pervasives (for succ) but doesn't use a lot of functions of List or Pervasives (e.g., List.iter, List.fold_left, Pervasives.print_endline). So most functions of modules Pervasives and List are removed from the bytecode executable.

If one dynamically loads some bytecode, for instance the previous program becomes
  let plop = List.map succ [1;2;3];;
  let _ = Dynlink.load "stuff.cmo";;
then stuff.cmo should not reference anything that may not exist, such as Pervasives.(@) since it has been removed by ocamlclean. And we are not supposed to know at compile-time what stuff.cmo needs from stdlib. Hence I guess everything should be kept and ocamlclean not used.

On the other hand, if we statically know what is in stuff.cmo, then why load it dynamically? (I guess the answer can be "just for fun" but I'm not so sure it's such a good answer :-)

Though, I'm not very familiar with Dynlink, and I'm not sure what "Dynlink.allow_only" really does...

I haven't tested using dynlink to load a self-sufficient module. I might work, but I don't really see how it can be usefull anyway...

Philippe Wang

On Nov 11, 2010, at 06:52 AM, Julien Signoles wrote:

> Hello,
> Is ocamlclean compatible with dynamic loading? That is code potentially used by some unknown dynamically-loaded code must be kept.
> --
> Julien