[m-dev.] module system discussion

Peter Ross peter.ross at miscrit.be
Tue Nov 20 00:06:18 AEDT 2001


On Mon, Nov 19, 2001 at 05:53:33PM +1100, Fergus Henderson wrote:
> S1.  `:- auto_import'.
> 
> 	There's a new declaration `:- auto_import <Modules>',
> 	where <Modules> is a list of fully-qualified module name.
> 	This may only occur in the interface section, not in the
> 	implementation section.  The effect is that if this
> 	declaration occurs in the interface for module foo,
> 	then any `:- import_module' or `:- use_module declaration'
> 	for `foo' is treated as if there was also a corresponding
> 	`:- import_module' or `:- use_module' declaration for
> 	the <Modules> specified in the `:- auto_import' declaration.
> 
> 	For example, if you have the following two modules,
> 
> 		:- module m1.
> 		:- interface.
> 		:- auto_import m2, m3.
> 		:- end_module m1.
> 
> 		:- module m4.
> 		:- interface.
> 		:- use_module m1.
> 		...
> 		:- end_module m4.
> 
> 	this would be equivalent to
> 
> 		:- module m1.
> 		:- interface.
> 		:- end_module m1.
> 
> 		:- module m4.
> 		:- interface.
> 		:- use_module m1.
> 		:- use_module m2, m3.
> 		...
> 		:- end_module m4.
> 
> 	This implies that entities in modules m2 and m3
> 	can be referred to
> 
> 	A variation on this proposal, which I will call S1 (b),
> 	is that there is a further restriction that the <Modules>
> 	listed in an `:- auto_include' declaration are only allowed
> 	to be sub-modules of the module in which the `:- auto_include'
> 	declaration occurs.
> 
>     This proposal would provide a solution to problems 3 ("zillion imports")
>     and 4 ("overloading") above.

The version that I have implemented is S1 (b).

> 
> S2. `:- include'.
> 
> 	There's a new declaration `:- include <Modules>',
> 	where <Modules> is a list of fully-qualified module name.
> 	This may only occur in either the interface or implementation
> 	section.  The effect is that the entities declared in the
> 	interfaces of the specified <Modules>, or *included* (directly
> 	or indirectly) in those interfaces, are *included* in the
> 	corresponding section of the containing module,
> 	which means that they can be referred to as
> 	if they were members of that section of the containing module.
> 	(By "the containing module", I mean the module in which the
> 	`:- include' declaration occurs.)
> 
> 	Apart from that, all the usual rules in the Mercury language
> 	reference manual apply.
> 
> 	Note that since the entities are only *included* in the
> 	containing module, rather than being *defined* in the containing
> 	module, the prohibition against defining multiple entities in
> 	a single module with the same kind (pred/func/type/etc.), name,
> 	and arity does not apply.
> 
>     This proposal would probide a solution to problems 3 ("zillion imports"),
>     4 ("overloading"), and 5 ("repackaging") above.
> 
The only drawback that I have come up to this proposal is the one that I
have mentioned in the email

http://www.mercury.cs.mu.oz.au/mailing-lists/mercury-developers/mercury-developers.0111/0088.html

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