[m-dev.] dummy types with user-defined equality/comparison

Julien Fischer juliensf at cs.mu.OZ.AU
Mon May 29 17:26:13 AEST 2006


On Mon, 29 May 2006 maclarty at cs.mu.OZ.AU wrote:

> On Mon, May 29, 2006 at 05:09:09PM +1000, Julien Fischer wrote:
> >
> > Currently the compiler will abort when confronted with a dummy type that has
> > user-defined equality or comparison.  Below are two proposals for fixing
> > this.  Which do people prefer?
> >
> > (1) Change the reference manual to say that discriminated union types
> >     whose body consists of a single zero-arity constructor may not have
> >     user-defined equality or comparison defined upon them.  (Plus change
> >     the compiler to emit the appropriate error mesages.)
> >
>
> I think this option is best, since if values of the type are restricted
> to one zero-arity function symbol then any two values of the type must
> compare as equal for all sound definitions of equality and comparison.

I guess (in quite rare circumstances) you might not want to allow values
of the type to be compared by defining comparison as throwing an exception
or something - otherwise I agree with you.

> > (2) Change the compiler so that it does not treat discriminated union types
> >     whose body consists of a single zero-arity constructor as dummy types.
>
> I thought that was how the compiler recognised dummy types.  Are you
> proposing to get rid of dummy types altogether?

Sorry, yes that is how it recognizes them.  I meant only in the case where
they have user-defined equality or comparison.

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