From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA16691 for caml-redistribution; Mon, 14 Jun 1999 17:49:01 +0200 (MET DST) 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 MAA14662 for ; Mon, 14 Jun 1999 12:54:16 +0200 (MET DST) Received: from maxime.u-strasbg.fr (maxime.u-strasbg.fr [130.79.75.36]) by nez-perce.inria.fr (8.8.7/8.8.7) with ESMTP id MAA18840 for ; Mon, 14 Jun 1999 12:54:14 +0200 (MET DST) Received: (from luther@localhost) by maxime.u-strasbg.fr (8.8.7/8.8.7) id MAA19336; Mon, 14 Jun 1999 12:55:38 +0200 (MET DST) Message-ID: <19990614125538.B19275@maxime.u-strasbg.fr> Date: Mon, 14 Jun 1999 12:55:38 +0200 From: Sven LUTHER To: Junbiao Zhang , caml-list@inria.fr Subject: Re: forward function definitions Reply-To: luther@dpt-info.u-strasbg.fr References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.2 In-Reply-To: ; from Junbiao Zhang on Wed, Jun 09, 1999 at 02:38:22PM -0400 Sender: weis On Wed, Jun 09, 1999 at 02:38:22PM -0400, Junbiao Zhang wrote: > Hi, > > We're developing a fairly large system with multiple function > definitions. It's inevitable that some functions may call other functions > defined later(may not even be recursive calls as in the case of > Sys.Signal_handle). My question is: how do I solve such a problem which is > extremely trival in other languages? Thanks. If the two functions are in different modules, just provide a interface file for them, and it should work ok but can cause some linker problems. 2 clean way of doing this are : * use the later called function as a parameter to the first called function : let register_signals_arg f = Sys.signal Sys.sigalrm (Sys.Signal_handle f) ... let a sigid = ... let register_signals = register_signals_arg a * Or you could define all this in the form of a module functor : module type XXX = sig val a : id -> ... end module Make_M (X : XXX) = struct let register_signals = Sys.signal Sys.sigalrm (Sys.Signal_handle X.a) end module ARG = struct let a sigid = ... end module M = Make_M ARG open M Friendly, Sven LUTHER