[m-dev.] Module qualification of typeclass methods

Tyson Dowd trd at cs.mu.OZ.AU
Tue Oct 30 17:23:29 AEDT 2001


On 29-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> DJ and I were discussing the merits of the following change.
> 
> Currently for the following code
> 
> :- module mod.
> :- typeclass foo(T) where
> [
>     bar(T) = int
> ].
> 
> 
> if we wish to use the fully qualified name for the method bar it is
> 
>     mod__bar(X)
> 
> However we could allow the typeclass declaration to introduce a new
> namespace, thus the fully qualified name would become
> 
>     mod__foo__bar(X)

Can you explain to the viewers at home what the problem is with

:- module mod.
:- module foo.
:- typeclass foo(T) where
[
    bar(T) = int
].
:- end_module foo.

Which appears to do the same thing...

> This change has the advantage that more than one typeclass at the same
> scope can have a method with the same name and for these names to be
> distinguishable.  This is useful for doing interoperabilty on the IL
> backend.  It makes the mapping between objects and typeclasses much more
> natural.
> 
> The disadvantages of this change are: it is not backwards compatible and
> it no longer allows a typeclass method to easily become a normal
> predicate, as any qualified uses of that name will have to be adjusted.
> 
> 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
> --------------------------------------------------------------------------

-- 
       Tyson Dowd           # 
                            #  Surreal humour isn't everyone's cup of fur.
     trd at cs.mu.oz.au        # 
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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