[m-dev.] Module qualification of typeclass methods
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Nov 16 01:55:44 AEDT 2001
On 07-Nov-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> On Wed, Nov 07, 2001 at 11:05:52AM +1100, Tyson Dowd wrote:
> > I also found it difficult to explain what the requirements are of the
> > extensions that are being proposed.
> >
> > Can you gather together a few of the example interfaces that you are
> > generating and finding difficult to use?
> >
> > And can you then list the problems that are happening with them?
>
> Here is an example of one way to map the System.Object class to Mercury
> (the current way we do it).
>
> :- module 'System'.
>
> :- interface.
>
> :- type 'Object'.
> :- pragma foreign_type('Object', il("[mscorlib]System.Object")).
>
> :- implementation.
>
> :- module 'System__Object'
> :- interface.
> :- typeclass 'Object'(T) where [
> % Instance method
> impure func 'GetHashCode'(T) = int
> ].
> :- instance 'Object'('System__Object').
>
> % Static method.
> :- impure func 'Equals'('System__Object', 'System__Object') = bool
>
> :- implementation.
>
> % ...
>
> :- end_module.
>
> :- end_module.
>
> The only real problem with this approach is that to use the
> System.Object class in Mercury you need to import both the System and
> System__Object modules. I would like a mechanism which would allow one
> to import just the System module and get all the required sub-modules at
> the same time.
Hmm... IMHO this is not a compelling example.
Why not just import both the System and System__Object modules?
That doesn't seem like such a terrible burden here.
Do you have any more compelling examples?
--
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