Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@cs.ru.nl>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] recursive modules: Cannot safely evaluate the	definition
Date: Fri, 04 Apr 2008 17:23:37 +0200	[thread overview]
Message-ID: <wwu63uxd4p2.fsf@tandem.cs.ru.nl> (raw)
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")

Jean-Christophe Filliâtre <Jean-Christophe.Filliatre@lri.fr>
writes:

   Keiko Nakata wrote:
   > Hello.
   > 
   > 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. 

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. 

Bye,

Hendrik


  reply	other threads:[~2008-04-04 15:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-04  8:44 Hendrik Tews
2008-04-04  9:00 ` [Caml-list] " Keiko Nakata
2008-04-04 12:44   ` Jean-Christophe Filliâtre
2008-04-04 15:23     ` Hendrik Tews [this message]
2008-04-04 15:45       ` Keiko Nakata
2008-04-04 16:17         ` Sebastien Ferre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=wwu63uxd4p2.fsf@tandem.cs.ru.nl \
    --to=tews@cs.ru.nl \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox