Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: forward function definitions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: luther sven <luther@s...>
Subject: Re: forward function definitions
On Mon, Jun 14, 1999 at 06:17:22PM +0200, Pierre Weis wrote:
> > 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.

Ah, but you can define a wrapper immediately following the definition of the forwarder function :

let f for () = ...

...

let for ... = ...
let true_f = f for

Friendly,

Sven LUTHER