[m-dev.] Module qualification of typeclass methods

Simon Taylor stayl at cs.mu.OZ.AU
Mon Nov 12 21:42:24 AEDT 2001


On 01-Nov-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 01-Nov-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > 
> > On 31-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > Fergus wrote:
> > > To make this clear:
> > > 
> > > :- module foo__bar.
> > > :- export_module baz__bar__foo.
> > > :- end_module.
> > > 
> > > Would replace all module qualifiers baz__bar__foo with foo__bar on the items
> > > in baz__bar__foo.
> > > 
> > > > % combining two modules into a single module:
> > > > :- module foo.
> > > > :- interface.
> > > > :- export_module bar.
> > > > :- export_module baz.
> > > > :- end_module foo.
> > 
> > How would this handle the case where `bar' and `baz' define
> > a predicate, type, mode, etc. with the same name?
> 
> That would be allowed, but attempts to refer to such
> a predicate, type, or mode `x' via the name `foo__x'
> might result in ambiguity errors.  These ambiguities
> could be resolved by referring to it via the name `bar__x'
> or `baz__x'.

When `:- export_module' or `:- include' is being used to
combine two modules, I think it's a bit ugly to have to
know how the combined module was constructed.

I also don't like the idea of relaxing the restriction that
there can only be a single predicate or function with a
given name in a module. That every predicate or function
has a unique fully qualified name without looking at the
argument types is very useful for readability.

Instead, I would suggest allowing renamings, for example
:- include bar where [pred x/1 is y].

This `:- include' proposal doesn't solve the problem of
including all of the sub-modules of modules such as
extras/complex_numbers/complex_numbers.m, where the whole
point of using sub-modules is that the functions in the
different sub-modules have the same name. I think that case
is more simply handled using the alternative form of
`:- include_module' I suggested earlier.

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