[m-dev.] Module qualification of typeclass methods

Peter Ross peter.ross at miscrit.be
Thu Nov 15 21:40:06 AEDT 2001


On Thu, Nov 15, 2001 at 09:11:00PM +1100, Fergus Henderson wrote:
> 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.
> 
OK thanks, I understand.
--------------------------------------------------------------------------
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