nested modules proposal (was: packages proposal)

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 13 15:16:58 AEDT 1998


On 13-Feb-1998, Andrew Bromage <bromage at cs.mu.OZ.AU> wrote:
> G'day.
> 
> Fergus Henderson wrote:
> 
> > I spent a lot of time thinking about my packages proposal last night
> > (couldn't sleep, actually), and I have come up with a new, simpler
> > proposal which I think would in fact be easier to implement.
> > So scrap the previous proposal, and replace it with this one.
> 
> I have a few comments.
> 
> > 1. Nested modules.
> > ------------------
> > 
> > Syntax:
> > 
> > 	A module may contain sub-modules, delimited by
> > 	`:- module' and `:- end_module declarations'.
> > 
> > 	Module names themselves be module-qualified.
>                                ^
> There's a qualifier missing.  Pick one of: must, should, may.

may.

> > 	(We should also add some new syntax for fully-qualified
> > 	module names, e.g. `:m1:m2:foo', but I can't think
> > 	of a workable syntax for it.)
> 
> I like that one, actually.

Yes, me too, but unfortunately it is not workable.

> This way, the empty module name is sort
> of the "root module".  However it doesn't work when using "__" as
> a module qualifier.

Actually it *does* work with "__": you could just write "__m1__m2__foo".
It doesn't work with `:' because `:' is a binary operator.

> Your suggestion doesn't mention private sub-modules.  Will we be
> supporting them or not?

Yes.

> > 	The mapping between module names and file names is
> > 	is implementation-dependent.
> 
> I'm not entirely happy about this.  You should be able to take some
> Mercury source written under one implementation and compile it on
> some other implementation without change.

This is an admirable goal.  However, I suggest that we delay standardization
of such a mapping until we have more practical experience.

> The only part of the
> compilation process that needs to understand this mapping, of course,
> is `mmake depend'.

The compiler also needs to know where to find the `.int' file
when it sees `:- import_module foo', or where to find the parent module's
`.m' file when a module begins with `:- module foo.bar'.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list