Re: [Scheme-reports] Inexact numbers and `eqv?`: the post I didn't want to make John Cowan (26 Nov 2012 07:54 UTC)

Re: [Scheme-reports] Inexact numbers and `eqv?`: the post I didn't want to make John Cowan 26 Nov 2012 07:50 UTC

Mark H Weaver scripsit:

> > For this sort of non-IEEE exact number, = is the Right Thing for `eqv?`.
> > There are no special cases of numbers that should be distinguished even
> > though they are not mathematically equal.
>
> * Can you provide an example of an application that requires
>   'eqv?' and '=' to agree for this type of number, and that
>   cannot be implemented in another way?

The shoe's on the other foot.  Can you provide an example of an
application that requires them to disagree on inexact numbers that
exclude NaN and negative zero?  Outside of those cases, equality and
operational equivalence are, well, operationally equivalent.

> * If 'eqv?' and '=' must agree, then why not use '=' instead?

Because there are things that have `eqv?` hard-coded into them,
like `case`.

> * Why does this application need two primitives to do the same
>   job, leaving none that can be used for memoization?

Memoizing this type of number can only be done with a predicate
equivalent to `=`.  If we are to memoize with `eqv?`, then we want
`eqv?` in this case to be the same as `=`.

> Can you please provide an example of an application that requires
> (eqv? (+ 1.0 3.0) (+ 2.0 2.0)) => #t and cannot be implemented in
> another way?

It's the other way around:  *if* `eqv?` on these numbers were implemented
by sameness of representation, there would be no guarantee that two
operationally equivalent numbers were the same by `eqv?`.  Fortunately,
no one has proposed this.

>
> Note that if an implementation can prove that two different
> representations of the same number are operationally equivalent,
> then my proposed definition permits 'eqv?' to return #t.

I am not bringing this forward as a counterexample to your proposal,
but for other reasons altogether.

--
Note that nobody these days would clamor for fundamental laws        John Cowan
of *the theory of kangaroos*, showing why pseudo-kangaroos are   cowan@ccil.org
physically, logically, metaphysically impossible.    http://www.ccil.org/~cowan
Kangaroos are wonderful, but not *that* wonderful.     --Dan Dennett on zombies

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports