[m-dev.] Foreign type compare and unification

Peter Schachte schachte at cs.mu.OZ.AU
Tue May 21 14:01:26 AEST 2002


On Tue, May 21, 2002 at 01:46:21PM +1000, Ralph Becket wrote:
> I don't think, however, that I want every type to be a member of every
> type class that has a complete set of default method implementations.
> That would lose me a good deal of error spotting on the part of the
> compiler.

No problem.  It wouldn't be hard to have a :- default_class
declaration that's just like a :- class declaration, except that it
adds the requirement that *every* method has a default implementation,
and means that every type is implicitly a member.  Or alternatively,
some addendum in a :- class declaration itself marks it as having
every type as a default instance.  This still has the advantage of
making this sort of class just a special case of an ordinary class.

> This is a problem for dynamically loaded code, but less so for
> statically linked programs.  Fergus has an argument that this is the
> right thing to do (I'll let him explain it.)

As I understand it, each type in Mercury can be an instance of a class
in at most one way.  So adding an instance declaration anywhere in the
program, or even just linking in a new module that contains an
instance declaration, can make a valid Mercury program invalid.  And
it does so in a way that doesn't have an obvious, easy work around.

-- 
Peter Schachte              He that waiteth for all men to be satisfied with
schachte at cs.mu.OZ.AU        his plan, let him seek eternal life, for he
www.cs.mu.oz.au/~schachte/  shall need it.
Phone: +61 3 8344 9166          -- Mark Twain 
--------------------------------------------------------------------------
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