From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 96558BB9C for ; Tue, 17 Jan 2006 09:55:32 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0H8tWgv001379 for ; Tue, 17 Jan 2006 09:55:32 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id JAA21216 for ; Tue, 17 Jan 2006 09:55:31 +0100 (MET) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.196]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k0H8tUTu014657 for ; Tue, 17 Jan 2006 09:55:31 +0100 Received: by zproxy.gmail.com with SMTP id m7so1587698nzf for ; Tue, 17 Jan 2006 00:55:30 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=cPnNAFQsRrjgSzjWJ57zSS4gGFICZ6rq5ZjZI2uXIFi9oiy7NU3YzLlz2RNiUwyOTo/BTDxR9K++BjX9ScBoa2hJqeXkv2oeIIhv/O8lJyIivCVhBCbal3/w2NDc9sx5r2ES3xLCsCRQpeMaR0yLkAEI7dlukgjxqqb1HbJAUtU= Received: by 10.36.196.6 with SMTP id t6mr5463647nzf; Tue, 17 Jan 2006 00:55:30 -0800 (PST) Received: by 10.36.224.7 with HTTP; Tue, 17 Jan 2006 00:55:30 -0800 (PST) Message-ID: <3dd983220601170055w5bd95adfjca47847809f3226e@mail.gmail.com> Date: Tue, 17 Jan 2006 00:55:30 -0800 From: Brendan Miller To: caml-list@inria.fr Subject: mutually recursive modules MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Miltered: at concorde with ID 43CCB104.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 43CCB102.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; recursive:01 ocaml:01 ocaml:01 compiler:01 dependancy:01 recursive:01 dependancy:01 doubly:01 doubly:01 mli:01 prev:01 prev:01 val:01 mutable:01 val:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 I'm new to ocaml. My understanding is that the ocaml compiler does not allow for circular dependancy of modules. What is the design reason for this? I don't think I've ever seen a language before with this limitation. Is it just to keep people from writing mutually recursive functions across modules? Suppose there are two classes, A and B defined in separate modules. Does the no circular dependancy rule preclude a doubly linked relationship between A and B? Let's say I want to create a doubly linked list with alternating element types. consider the following code, which fails to compile: A.mli: class c : object method set_prev : B.c -> unit method get_prev : B.c method set_next : B.c -> unit method get_next : B.c end A.ml class c =3D object val mutable m_prev : B.c option =3D None val mutable m_next : B.c option =3D None method set_prev prev =3D m_prev <- prev method get_prev =3D m_prev method set_next next =3D m_next <- next method get_next =3D m_next end;; B.mli class c : object method set_prev : A.c -> unit method get_prev : A.c method set_next : A.c -> unit method get_next : A.c end B.ml class c =3D object val mutable m_prev : A.c option =3D None val mutable m_next : A.c option =3D None method set_prev prev =3D m_prev <- prev method get_prev =3D m_prev method set_next next =3D m_next <- next method get_next =3D m_next end;; This is annoying. Of course I need a way to make classes from different modules recur. Is there a syntax for specifying an interface to the type I'm recurring with without that type actually being in the same module? That would be somewhat cumbersome, but would actually more properly separate the types than the code above. In general, could someone clarify the rational for making type recursion so cumbersome? thx