[m-rev.] Add `:- initialise' directive to the language.

Mark Brown mark at cs.mu.OZ.AU
Wed Aug 17 16:33:46 AEST 2005


On 17-Aug-2005, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Index: doc/reference_manual.texi
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
> retrieving revision 1.320
> diff -u -r1.320 reference_manual.texi
> --- doc/reference_manual.texi	14 Aug 2005 05:44:58 -0000	1.320
> +++ doc/reference_manual.texi	17 Aug 2005 04:44:22 -0000
> @@ -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.
> +Such modules may include any number of @samp{initialise} directives
> +in their implementation sections.
> +An @samp{initialise} directive takes the following form:
> +
> + at example
> +:- initialise initpredname.
> + at end example
> +
> +where the predicate @samp{initpredname} must be declared with the following
> +signature:

There should probably be a `/2' in there.  Presumably initpredname/3, for
example, can also be defined (but will be distinct from the initialisation
predicate).

> +
> + at example
> +:- pred initpredname(io::di, io::uo) is det.
> + at end example

Is there any reason not to allow cc_multi?

> +
> +The effect of the @samp{initialise} declaration is to ensure that
> + at samp{initpredname} is invoked before the program's @samp{main}
> +predicate.  Initialisation predicates within a module are executed in the
> +order in which they are specified, although no order may be assumed between
> +different modules or submodules.

You'll probably need to update the Semantics section of the reference manual
too.

Cheers,
Mark.

--------------------------------------------------------------------------
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