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 SAA18459 for caml-redistribution; Mon, 14 Jun 1999 18:23:36 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA22627 for ; Mon, 14 Jun 1999 18:17:24 +0200 (MET DST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.8.7/8.8.7) with ESMTP id SAA10002; Mon, 14 Jun 1999 18:17:22 +0200 (MET DST) Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA23666; Mon, 14 Jun 1999 18:17:22 +0200 (MET DST) From: Pierre Weis Message-Id: <199906141617.SAA23666@pauillac.inria.fr> Subject: Re: forward function definitions To: luther@dpt-info.u-strasbg.fr Date: Mon, 14 Jun 1999 18:17:22 +0200 (MET DST) Cc: caml-list@inria.fr In-Reply-To: <19990614125538.B19275@maxime.u-strasbg.fr> from "Sven LUTHER" at Jun 14, 99 12:55:38 pm X-Mailer: ELM [version 2.4 PL24 ME8] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 : That's a neat solution, although this trick works only when the ``later defined'' function is monomorphic, or at least is not polymorphically called (the same problem arises with the reference trick). Furthermore, this extra argument is a bit confusing, since, as a forward, it should always be exactly the same value and nothing helps the reader to understand this. Furthermore, the compiler has no ways to warranty this semantics. > * Or you could define all this in the form of a module functor : In this case, you can polymorphically use a forward definition, although is appears to me to be really a heavy loaded syntactic way of defining forwards... Friendly, Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://cristal.inria.fr/~weis/