[m-dev.] special module initialisation code

Tyson Dowd trd at cs.mu.OZ.AU
Fri Mar 31 15:55:24 AEST 2000


On 21-Mar-2000, David Overton <dmo at ender.cs.mu.oz.au> wrote:
> Hi,
> 
> I am currently in the process of writing a new module to integrate
> Peter Schachte's C implementation of ROBDDs with Mercury.  The
> interface to Peter's code is declarative, except that an
> initialisation procedure needs to be called to set up some tables
> before any of the other procedures in the module can be used.
> 
> It would be nice if there were some way of automatically getting this
> procedure called at program startup if the ROBDD module has been
> imported.
> 
> I believe a C function `mercury__<module>__init()' is generated for
> each module and called when the program starts up.  This seems like a
> logical place to put such code.
> 
> One possibility is to add a new pragma, `c_init_code', which is
> similar to `pragma c_header_code', except that it puts the code inside
> the `mercury__<module>__init()' function instead of at the top of the
> .c file.
> 
> How does this sound?  Does anyone have any alternative suggestions?

Typically I solve this problem by making the delcarative interface do
the initializtion.  This can be done in the equivalent of the data
structure initialization function (if you thread a data structure to
each operation).

Alternately, if there is no data struction initialization, you can do a
"first-time" test for each operation.  It's not clear whether this would
be too expensive for your application.

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't eveyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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