[m-dev.] special module initialisation code

Thomas Conway conway at cs.mu.OZ.AU
Tue Mar 21 16:36:31 AEDT 2000


On Tue, Mar 21, 2000 at 04:33:46PM EST, Zoltan Somogyi wrote:
> On 21-Mar-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > You'd need to add extra support in util/mkinit.c.
> > Also it might increase build times a bit.
> > 
> > However, if you are going to add such an automatic initialization
> > feature, then you need to consider the order-of-initialization
> > problem.  What happens if the initialization code for one module
> > depends on the initialization code for some other module already
> > having been run?  This is a fairly common situation, so if you
> > are going to add such a feature, then IMHO it really ought to
> > address that issue.  This of course will further complicate the
> > implementation...
> 
> A simple near-term approach would be to add to mkinit.c an option
> that gives a list of C functions to call before invoking main/2.
> This avoids the problem of paging in hundreds of initialization functions
> (since usually there will be zero or one such functions), and throws the
> problem of determining the proper order back to the programmer (who has
> to give the functions in their order of invocation).
> 
> Note that the invoked C functions may call back to Mercury code, so
> they would need to be called after the Mercury environment has been set up.
> 
> This scheme is not ideal, since the designer of a library may now have to tell
> the users of the library to give some flags to c2init to pass on to mkinit,
> but I think it gets 90% of the benefit for 10% of the cost.
> 

You could modify mmake to have a variable to pass mkinit - eg MKINIT_FLAGS.

-- 
 Thomas Conway )O+     Every sword has two edges.
     Mercurian            <conway at cs.mu.oz.au>
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list