[m-dev.] for review: cfloat.m

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Jan 29 16:55:46 AEDT 2000


On 26-Jan-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > Rather than adding `cfloat__unify', you could just say
> > `... where equality is cfloat__eq'.  There doesn't seem
> > to be much benefit in adding another name for the same
> > operation.
> 
> That would require adding an (in,in) mode to cfloat__eq, which it doesn't
> have such a mode at the moment.

Ah.  Yes, that's what the language reference manual says.
But what the compiler actually implements is a bit more permissive:
you can use any mode that can be called from an `(in, in) is semidet' mode.
For example, something with mode `(in(any), in(any) is det' is fine.

I think we should modify the language reference manual to allow this.
See the diff below.

> I thought that may cause compatibility problems. Was I wrong?

I'm pretty sure that adding a new declaration for an implied mode to
something that already has more than one mode can't cause compatibility
problems.  So you could go ahead and add a `(in, in) is semidet'
mode to cfloat__eq.  But I think it would be better to instead
change the language reference manual to reflect the compiler's
current behaviour, and then you can just use cfloat__eq unchanged.

Comments?

----------

Estimated hours taken: 0.5

doc/reference_manual.texi:
	Document that equality predicates can have declarations
	that are more general than `pred(T::in, T::in) is semidet'.

Workspace: /d-drive/home/hg/fjh/mercury
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.162
diff -u -d -r1.162 reference_manual.texi
--- doc/reference_manual.texi	1999/12/13 13:30:47	1.162
+++ doc/reference_manual.texi	2000/01/29 05:51:37
@@ -2260,18 +2260,27 @@
         subset(S2, S1).
 @end example
 
-A type declaration for a type @var{T} may contain a
+A type declaration for a type @samp{foo(T1, @dots{}, TN)} may contain a
 @samp{where equality is @var{equalitypred}} specification only
 if the following conditions are satisfied:
 
 @itemize @bullet
 @item
- at var{T} must be a discriminated union type; it may not be an
-equivalence type
+ at The type @samp{foo(T1, @dots{}, TN)} must be a discriminated union type;
+it may not be an equivalence type
 
 @item
- at var{equalitypred} must be the name of a predicate with type
- at samp{pred(T, T)} and mode @samp{(in, in) is semidet}.
+ at var{equalitypred} must be the name of a predicate which can
+be called with two ground arguments of type @samp{pred(foo(T1, @dots{}, TN))},
+and whose determinism in that mode is @samp{semidet}.
+Typically the predicate would have type
+ at samp{pred(foo(T1, @dots{}, TN), foo(T1, @dots{}, TN)}
+and mode @samp{(in, in) is semidet}, but it is also legal
+for the type or the mode's initial insts to be more general
+(e.g. the type could be just the polymorphic type @samp{pred(T, T)}
+and for the mode's final insts or the determinism to be more
+specific (e.g. the determinism could be any of @samp{det},
+ at samp{failure} or @samp{erroneous}).
 
 @end itemize
 
-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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