[m-dev.] Foreign type compare and unification

Ralph Becket rafe at cs.mu.OZ.AU
Tue May 21 13:46:21 AEST 2002


Peter Schachte, Tuesday, 21 May 2002:
> > I was talking about this yesterday with Mark.  One idea was that we
> > allow declarations of the form
> > 
> > 	:- default_instance c(T) where [...].
> > 
> > which would essentially make all types T an instance of type class c/1,
> > and provide default method implementations (an explicit c(T') instance
> > declaration for T' overriding the default_instance declaration for T.)
> 
> Sounds good to me.
> 
> I'd actually prefer, though, to allow class declarations to provide
> default methods.  If all methods of a class have defaults, then every
> type could be an instance by default.  This gets you the same
> facility, but has the added advantage of supporting default methods
> for ordinary classes, which seems like a useful feature.

I agree that being able to provide default implementations in the type
class declaration would be a good thing.

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.

> > Mark objected that this would be bad in that the behaviour of a program
> > could change if someone later added an explicit c(T') instance
> > declaration.
> 
> True enough, but how much worse is that than the current state of
> affairs in which adding an instance declaration in some unrelated
> module in your application, or even just linking in a new library
> module, can cause your application not to compile (actually, link) at
> all?

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.)

- Ralph
--------------------------------------------------------------------------
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