[m-dev.] Module qualification of typeclass methods
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Oct 31 20:16:34 AEDT 2001
On 31-Oct-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > (When discussing these things, it helps to use precise language ;-)
> >
> > > Each of these typeclasses may have names which
> > > conflict with the same name in another typeclass, hence we have to place
> > > each typeclass in a seperate sub-module. The mscorlib assembly has 883
> > > public types in it, so a reasonable use of this library may require 20
> > > or 30 imports just to use a subset of its types effectively. I can
> > > assure you that this is very annoying.
> >
> > Could you give an example?
> >
> > Note that having 20 or 30 imports is not uncommon for modules in the
> > Mercury compiler directory. I haven't found that to be particularly
> > annoying.
>
> Yes but each of those imports contains more functionality then just one
> type. Imagine if you had to do an import for each type in the prog_data
> module that you wanted to use.
Hmm, well, maybe. I can see that this could be a bit tedious,
but I'm not sure that this is a problem which is so important
that we need to extend the language to solve it.
> Actually there is two problems. The first is that which I explained above.
> The next is that not only do you need to do an import to use that type, but
> if you want to use a method that the type has inherited from a parent class
> you must also import the module which defines that parent class. So to use
> one type correctly you may need to import its whole inheritance hierachy.
> This seems very inelegant to me.
Ah. I see. This one I find more convincing.
This problem could be remedied using the `:- export_module'
that I proposed in an earlier message: each module could
contain a `:- export_module' declaration for the module
corresponding to the parent class.
But `:- export_module' is just syntactic sugar for
a bunch of equivalence types and forwarding procedures.
Since you are generating all this code from a tool anyway,
you should be able to modify the tool to emit these
equivalence types and forwarding procedures.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "... it seems to me that 15 years of
The University of Melbourne | email is plenty for one lifetime."
WWW: <http://www.cs.mu.oz.au/~fjh> | -- Prof. Donald E. Knuth
--------------------------------------------------------------------------
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