[m-rev.] for review: module qualification of equality preds

Fergus Henderson fjh at cs.mu.OZ.AU
Mon May 19 14:09:26 AEST 2003


On 19-May-2003, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> The compiler was not module qualifying the `where equality is ...'
> part of type declarations in interface files. This could cause the
> compiler to use the wrong predicate in importing modules if the
> user-defined equality predicate was not exported.
> 
> To avoid this problem we now require user-defined equality or
> comparison predicates for a type to be defined in the same module
> as the type. This is the only simple way to module qualify the
> unification predicates in interface files without running
> typechecking.

OK, that seems fine; it's not an onerous restriction, anyway,
since if need be you can easily define wrapper predicates that
just call some other predicate.

> +++ doc/reference_manual.texi	19 May 2003 03:03:21 -0000
> @@ -3466,6 +3466,9 @@
>  The equality predicate must be ``pure'' (@pxref{Impurity}).
>  
>  @item
> +The equality predicate must be defined in the same module as the type.
> +
> + at item
>  @var{equalitypred} should be an equivalence relation; that is, it must be
>  symmetric, reflexive, and transitive.  However, the compiler is not required
>  to check this at footnote{If @var{equalitypred} is not an equivalence relation,
> @@ -3534,6 +3537,9 @@
>  
>  @item
>  The comparison predicate must also be ``pure'' (@pxref{Impurity}).
> +
> + at item
> +The comparison predicate must be defined in the same module as the type.

Don't the equality and comparison predicates also need to be exported
(i.e. declared in the interface section) if the type is exported?
That seems to be what your test case is testing.

It may be worth testing a few more cases, e.g.
- the case of module A defining the equality predicate,
  module B defining the type and importing A.
- the case of module A defining the equality predicate and the type,
  and module B importing module A and defining another predicate with
  the same name as the equality predicate.

-- 
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-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list