Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Emmanuel Engel <Emmanuel.Engel@lri.fr>
To: Vyskocil Vladimir <vyskocil@math.unice.fr>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: Modules mutuellement recursifs ?
Date: Tue, 18 Nov 1997 14:52:14 +0100	[thread overview]
Message-ID: <34719D8E.77FD@lri.fr> (raw)
In-Reply-To: <347170C1.F92F478B@math.unice.fr>

Si je comprend bien le but est d'ecrire 


let rec f x = if x = 0 then 0 else g (x - 1)
and     g x = if x = 0 then 1 else f (x - 1);;

en mettant chacune de ces fonctions dans un module different.
Je suis a peut pres sur qu'il n'est pas possible d'ecrire 
des modules mutuellement recursifs. Sans aller jusqu'a tout
mettre directement dans un meme fichier, il est posssible de 
faire le bricolage suivant (qui peut etre reparti dans 
plusieurs fichiers dictincts):

module M 
    (M1:sig val f: (int -> int) -> int -> int end) 
    (M2:sig val g: (int -> int) -> int -> int end) =
  struct
    let rec f' x = M1.f g' x
    and     g' x = M2.g f' x
    module M1 =
      struct
	let f = f' 
      end
    module M2 = 
      struct 
	let g = g'
      end
  end;;

module M1' = 
  struct
    let f g' x = if x = 0 then 0 else g' (x - 1)
  end;;
    
module M2' =  
  struct
    let g f' x = if x = 0 then 1 else f' (x - 1);;
  end;;

module MM1M2 = M(M1')(M2');;
module M1 = MM1M2.M1;;
module M2 = MM1M2.M2;;

-- 

- Emmanuel Engel




      reply	other threads:[~1997-11-18 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-18 10:41 Vyskocil Vladimir
1997-11-18 13:52 ` Emmanuel Engel [this message]

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=34719D8E.77FD@lri.fr \
    --to=emmanuel.engel@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=vyskocil@math.unice.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