[m-dev.] Module qualification of typeclass methods

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 15 21:11:00 AEDT 2001


On 15-Nov-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> Fergus wrote:
> > On 15-Nov-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > On Thu, Nov 15, 2001 at 04:43:39PM +1100, Fergus Henderson wrote:
> > > > For cases like extras/complex_numbers, the ambiguity will be
> > > > resolved by the types of the arguments.
> > >
> > > Currently we don't allow overloading of predicates with the same name
> > > and arity in the same module.  So assuming the arity is the same I don't
> > > see how we would resolve the ambiguity.
> >
> > The idea is that we would effectively allow overloading of predicates
> > with the same name and arity iff the overloading was introduced via a
> > `:- include' declaration.
>
> But in solving this problem, wouldn't it also solve the problem for
> predicates with the same name/arity located in one module.  After all to the
> user they appear to come from one module.  It seems a bit strange to me that
> we can allow this type of overloading by using a cunning trick, but not
> allow it the straight forward way.

The point of doing it this way is that the predicates are all *defined*
in different modules, even though they can be *referenced* using the
same module qualifier.

This means that

	(1) For every predicate, the triple consisting of the
            *defining* module name, predicate name, and arity
	    uniquely identifies that predicate.

	    Hence the compiler, debugger, profiler, mangler, demangler, etc.
	    don't need to include the argument types in predicate names.
	    This is good because (a) modifying all of that software to
	    include the argument types would be a lot of work
	    and (b) 99% of the time, including the argument types would
	    be extra verbosity that you don't want or need.
	    This extra verbosity is a pain: it makes it harder
	    to understand compiler error messages,
	    to fit profiling output on a single screen or page,
	    and so on.

and	

	(2) There is no ambiguity about which predicate a given *clause*
	    belongs to.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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