[m-dev.] Re: for review: big rats
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Apr 10 00:16:28 AEST 1998
On 09-Apr-1998, Bert Thompson <aet at hydra.cs.mu.oz.au> wrote:
> Fergus Henderson <fjh at cs.mu.OZ.AU> writes:
>
> Fergus,
>
> Thanks for the suggestions. I've made the changes, with one remark below.
>
> |The way to defining equality for a type is with `where equality is <blah>'
> |in the type declaration, rather than by defining an =/2 predicate.
> |It's probably a bug if the compiler does not at least warn you
> |if you try to do that.
>
> |In this case, the builtin unification will do the correct thing, so you
> |can just delete this predicate. However, a comment next to the type
> |definition about the type's invariant and why it is needed (to ensure
> |that the builtin equality gives correct results) would be a good idea.
>
> I've done this, but I think adding the `where equality is <blah>'
> approach may be preferable since it makes the code blindingly obvious:
> it does what it says not what the comments say.
> (Who has any faith in comments?)
I understand the principle, but in this case you have to use a comment,
because adding the `where equality is <blah>' has some undesirable
side-effects. In particular, if you have a user-defined equality
predicate, then the compiler thinks that the representation might
be a non-canonical one, and hence by default infers lots of things
as cc_multi rather than det (to make things det, you have to insert
various promises in appropriate places, and currently the way of
doing that is neither elegant nor efficient).
> Anyway, here's the diff...
...
> + % The rational_norm/2 predicate generates rationals in this
> + % normal form.
s/predicate/function/
Otherwise, that looks fine, so once the integer.m module is in,
please commit it (you can commit these two together, I suppose).
Oh, one more thing: you should add a brief comment to the NEWS file. :->
--
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.
More information about the developers
mailing list