[m-rev.] for review: require module a.b to be a.b.m without mmc -f

Julien Fischer jfischer at opturion.com
Sun Jan 12 19:16:32 AEDT 2020


Hi Zoltan,

On Sun, 12 Jan 2020, Zoltan Somogyi wrote:

> For review, and maybe a tryout, by Julien or Peter.

...

> Insist that without mmc -f, module a.b.c be in a.b.c.m.
> 
> compiler/parse_module.m:
>     Require that :- module declarations specify the expected name.
>     The name may be expected because it exactly matches the filename
>     (as above), or because mmc -f has recorded the actual name
>     as the expectation.
>
>     Factor report_module_has_unexpected_name out of
>     check_module_has_expected_name, since it is needed on its own.
>     Simplify its code.
>
>     Simplify the code for doing checks on :- end_module declarations.
> 
> doc/reference_manual.texi:
>     Document this change in the reference manual.texi.
> 
> slice/Mmakefile:
>     Run mmc -f *.m before making dependencies, because the modules copied
>     from mdbcomp have non-fully-qualified filenames.
> 
> tests/submodules/ts.tsub.m:
>     Provide the full name of this module in its :- module declaration.
> 
> tests/submodules/initialise_parent.initialise_child.m:
>     Fix white space.
> 
> tests/submodules/*.*.m:
>     Move separate submodules to their fully qualified filenames.

...


> diff --git a/doc/reference_manual.texi b/doc/reference_manual.texi
> index d5e7bd565..c6828c147 100644
> --- a/doc/reference_manual.texi
> +++ b/doc/reference_manual.texi
> @@ -5342,12 +5342,21 @@ Each of the named sub-modules in an @samp{:- include_module} declaration
>  must be defined in a separate source file.
>  The mapping between module names and source file names
>  is implementation-defined.
> -(For a module named @samp{foo.bar.baz},
> -The University of Melbourne Mercury implementation
> -requires the source to be located in a file named
> - at file{foo.bar.baz.m}, @file{bar.baz.m}, or @file{baz.m}.)
> -The separate source file must contain the declaration (interface)
> -and definition (implementation) of the sub-module.
> +The University of Melbourne Mercury implementation requires that

Are we still referring to it as the "The University of Melbourne Mercury implementation"?
(The reference manual seems to be split as to whether its that or simply the 
the Melbourne Mercury impelmentation.)

> + at itemize
> + at item @emph{either} every module should be

s/should/must/

> +in a file named whose name is the module name followed by @samp{.m},

     ... is the fully qualified module name ...

> +(so a module named e.g. @samp{foo.bar.baz},
> +must be in a file named @file{foo.bar.baz.m})
> + at item @emph{or} that the programmer tell the implementation
> +about which files contain which modules
> +using a command such as @samp{mmc -f *.m}.
> +(Alternatively, you could replace the @samp{*.m} in that command
> +with a list of the file names of all the Mercury modules in the program.)
> + at end itemize
> +
> +The source file of a separate sub-module must contain
> +the declaration (interface) and definition (implementation) of the sub-module.
>  It must start with a @samp{:- module} declaration
>  which matches that in the @samp{:- include_module} declaration in the parent,
>  followed by the interface and (if necessary) implementation sections,

...

> diff --git a/slice/Mmakefile b/slice/Mmakefile
> index ad7bea30e..4e8a0d8a6 100644
> --- a/slice/Mmakefile
> +++ b/slice/Mmakefile
> @@ -88,7 +88,14 @@ endif
>  .PHONY: depend
>  depend:	$(MDBCOMP_MODULES) $(DEPENDS)
> 
> -$(DEPENDS): SLICE_FLAGS $(MDBCOMP_MODULES)
> +$(DEPENDS): Mercury.modules SLICE_FLAGS $(MDBCOMP_MODULES)
> +
> +# This directory contains source files for which the module
> +# name doesn't match the file name, so smart recompilation
> +# won't work without the Mercury.modules file.
> +.PHONY: Mercury.modules
> +Mercury.modules: SLICE_FLAGS

You shouldn't need a .PHONY directive there.

> +	$(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) -f *.m

I think you also need to update the realclean_local target to remove
Mercury.modules.

The rest looks fine.

Julien.


More information about the reviews mailing list