[mercury-users] Inaccuracy in language definition ?

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Jul 16 19:42:21 AEST 2001


On 16-Jul-2001, Holger Krug <hkrug at rationalizer.com> wrote:
> "The Mercury Language Reference Manual", sec. 10.2, Instance declarations,
> states:
> 
> "The types in an instance declaration must not be abstract types which
> are elsewhere defined as equivalence types. ... These restrictions
> ensure, that there are no overlapping instance declarations, i.e. for
> each typeclass there is at most one instance declaration that may be
> applied to any type (or sequence of types)."
> 
> I cannot imagine why the restriction cite should be necessary

It's needed to make it easy to detect overlapping instance declarations,
which are prohibited because they semantic difficulties and make
intermodule optimization difficult.

> and how it might be implemented.
>
> In the case of abstract types, the compiler cannot check, how the type
> is defined.

The check is done at link-time, not at compile time.

In our current implementation we do this by generating symbols
that will result in duplicate symbol errors from the system linker
if there are overlapping instance declarations.

(Unfortunately the system linker doesn't detect these errors in all
cases, so in the future we would like to adopt a slightly more
sophisticated approach where the check was done by `ml', the Mercury
linker, rather than relying on the system linker.)

> Even more, it seems not necessary for the compiler to
> recognize, how an abstract type might be defined, because for the
> compiler the abstract type and the other type, it might be defined to
> be equivalent with, are not interchangeable.

That approach would mean that the a goal might have different
semantics depending on which module it was in, even when all
the names in the goal are fully module-qualified.  That would
make intermodule optimization difficult.

I agree that there are significant drawbacks to our current approach,
but all the other approaches also seem to have even worse drawbacks.

For more information on this, see
<http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-users/mercury-users.9902/0001.html>.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list