[m-rev.] Add `:- initialise' directive to the language.
Ralph Becket
rafe at cs.mu.OZ.AU
Thu Aug 18 15:17:38 AEST 2005
Julien Fischer, Wednesday, 17 August 2005:
>
> > @@ -4537,6 +4555,32 @@
> > (The work-around is to use separate sub-modules instead of nested
> > sub-modules, i.e.@: to put the sub-modules in separate source files.)
> > @end itemize
> > +
> > + at node Optional module initialisation
> > + at section Optional module initialisation
> >
> > +Some modules that interact with foreign libraries or services
> > +require special initialisation before use.
>
> I suggest: Modules that interact ... may require ...
Fixed.
> It's probably worth mentioning that duplicate initialisation predicate
> are executed twice. (Actually, I'm not convinced that this is such
> a good idea - I can think of some (foreign) libraries that should
> only be initialised once and it would be preferable if the compiler
> could pick up accidental attempts to do it twice).
I've put an XXX in the code at the appropriate point.
> > Index: runtime/mercury_wrapper.c
> > ===================================================================
> > RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
> > retrieving revision 1.149
> > diff -u -r1.149 mercury_wrapper.c
> > --- runtime/mercury_wrapper.c 1 Aug 2005 02:26:18 -0000 1.149
> > +++ runtime/mercury_wrapper.c 17 Aug 2005 03:10:36 -0000
> > @@ -339,6 +339,7 @@
> > #ifdef MR_DEEP_PROFILING
> > void (*MR_address_of_write_out_proc_statics)(FILE *fp);
> > #endif
> > +void (*MR_address_of_init_modules_required)(void);
> >
> > MR_TypeCtorInfo MR_type_ctor_info_for_univ;
> > MR_TypeInfo MR_type_info_for_type_info;
> > @@ -609,6 +610,9 @@
> >
> > /* initialize the Mercury library */
> > (*MR_library_initializer)();
> > +
> > + /* run any ...*/
> > + (*MR_address_of_init_modules_required)();
> >
> What's the ellipses for?
Zoltanism :-) Fixed.
> > +
> > +:- implementation.
> > +
> > +:- initialise i1.
> > +:- initialise i2.
> > +
> > +:- pred i1(io::di, io::uo) is det.
> > +i1(!IO) :- io.print("This is the first initialise pred, i1/2.\n", !IO).
> > +
> > +:- pred i2(io::di, io::uo) is det.
> > +i2(!IO) :- io.print("This is the second initialise pred, i2/2.\n", !IO).
> > +
> > +main(!IO) :- io.print("This is main/2.\n", !IO).
> > +
>
> If we're going to support multiple instances of the same intialiser then
> you should test that here as well.
Since we're undecided on that point, I'll omit that test.
> You should add a test to tests/invalid to test what happens when the
> predicate in the initialise declaration doesn't exist.
Done.
-- Ralph
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list