From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.7 required=5.0 tests=AWL,MIME_BAD_ISO_CHARSET autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 94C45BBCA for ; Fri, 4 Apr 2008 17:24:57 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Al8BAO/k9UeDrhCRiGdsb2JhbACRTAEBAQ8mmX0 X-IronPort-AV: E=Sophos;i="4.25,605,1199660400"; d="scan'208";a="9202463" Received: from smeltpunt.science.ru.nl ([131.174.16.145]) by mail2-smtp-roc.national.inria.fr with ESMTP; 04 Apr 2008 17:24:57 +0200 Received: from tandem.cs.ru.nl (tandem.cs.ru.nl [131.174.142.18]) by smeltpunt.science.ru.nl (8.13.7/5.24) with ESMTP id m34FOv1a007166 for ; Fri, 4 Apr 2008 17:24:57 +0200 (MEST) Received: from tews by tandem.cs.ru.nl with local (Exim 4.63) (envelope-from ) id 1Jhnmj-00088n-0U for caml-list@yquem.inria.fr; Fri, 04 Apr 2008 17:24:57 +0200 From: Hendrik Tews To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the definition References: <18421.59994.153567.662401@tandem.cs.ru.nl> <20080404.180015.125124978.keiko@kurims.kyoto-u.ac.jp> <47F622A5.9060707@lri.fr> Date: Fri, 04 Apr 2008 17:23:37 +0200 In-Reply-To: <47F622A5.9060707@lri.fr> (Jean-Christophe =?iso-8859-1?Q?Fil?= =?iso-8859-1?Q?li=E2tre's?= message of "Fri, 04 Apr 2008 14:44:21 +0200") Message-ID: User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-latin-1 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.63 on 131.174.16.145 X-Spam: no; 0.00; hendrik:01 tews:01 tews:01 recursive:01 filliatre:01 filliatre:01 lri:01 functors:01 recursive:01 ocaml:01 submodules:01 functors:01 functor:01 compiler:01 hendrik:01 Jean-Christophe Filli=E2tre writes: Keiko Nakata wrote: > Hello. >=20 > I think that functors cannot be recursive in the current OCaml. They can: [example deleted] For those who are interested but were too lazy to read the paper that Keiko pointed to: In a set of recursive modules every dependency cycle has to go through a safe module, whose signature consists only of functions, lazy values and exceptions and submodules with the same requirement. Initialization first initializes all safe modules by providing function bodies that throw execptions. Then initialize the remaining modules in the order of their dependency. In the end the functions in the safe modules are replace in place with the right closures. For this replacement trick to work you need to know the size of the safe modules. Functors are closures whose size cannot determined from their signature, thus functors are never safe. This does not exclude functors in recursive modules. It only means that apart from the functors you need at least one safe module. See 7.9 in the reference manual for a very sensible example with a functor. If there are dependency cycles without a safe module, you apparently get the "Cannot safely evaluate ..." error.=20 If you have dependency cycles with two or more safe modules than the compiler might choose an initialization order that does not work. Then it might help to make some of the safe modules unsafe.=20 Bye, Hendrik