[m-dev.] Foreign type compare and unification

Mark Brown dougl at cs.mu.OZ.AU
Fri May 24 16:12:58 AEST 2002


On 24-May-2002, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> On Thu, May 23, 2002 at 02:45:01PM +1000, Mark Brown wrote:
> > > But when someone else using that type in another way in another
> > > part of the code declares that type to be in a class (and define its
> > > methods), it does not make sense that this should have any effect on
> > > my code.
> > 
> > Do you mean an effect on the validity of your code, or on the behaviour
> > of your code?
> 
> Both.
> 
> > If you mean the latter, then aren't we in violent
> > agreement?
> 
> I don't think so.  As I understand it, you still want some random
> distant piece of code to be able to declare that string is an instance
> of comparable, and my code should benefit from it.

Urk, no.  I was making the unstated assumption that the instance
declaration in question is visible in the given scope.

You obviously didn't read my unstated assumption.  ;-)

I would argue that
> unless string is made an instance of comparable in the interface of
> the module that defines string, or my code has such a declaration,
> then my code should not consider string to be an instance of
> comparable.  I'd rather get a compile-time error (not a link-time
> error) if my code tries to compare two strings, or passes strings to a
> predicate that does so.

Compile-time error is fine.  Link-time error is not as good, but still
acceptable to me.  With default instance methods, though, you would get
no error at all, but the behaviour of your program could change.  It is
this that I am opposed to.

Cheers,
Mark.

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