[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Scheme-reports] Formal Comment: R7RS 'eqv?' cannot be used for reliable memoization



Ray Dillinger scripsit:

> First: is it the case that an implementation which does not provide
> NaN and -0.0 can be a correct implementation of R7RS?

Yes.  They are in fact described in the section "Implementation
extensions".

> If so, is there a standard way for portable code to discover whether the
> hosting implementation does or does not provide them without invoking
> an error?

There cannot be, in principle.  For one thing, R7RS (like R5RS)
does not require an implementation to support inexact numbers at all.
For another, in circumstances where implementation A would deliver -0.0,
implementation B might report a fatal implementation restriction.

But setting aside these relatively crude points, on a system which
distinguishes negative zero, (log -1.0-0.0i) will be 0.0-(pi)i rather
than 0.0+(pi)i, because the branch cut for log passes between 0.0 and
-0.0, so to speak.  This is a consequence of identifying 0.0 with "zero
or a positive number too small to represent" and -0.0 with "zero or a
negative number too large to represent".

> Assume someone is writing code in an implementation which does not
> provide NaN.  How would they produce code which handles NaN, -0.0,
> etc, specially but does not invoke a syntax error on their own nor any
> other implementation?

A syntax error isn't really the issue.  (/ (- (/ 1.0 0.0))) will generate
-0.0 if there is one, provided the system doesn't choke on the divisions.

> Uh, that's kind of a "wrong answer" on this level.  It is the goal
> of this process to produce something that's generally usable, right?

That doesn't mean there aren't edge cases.  This is one such edge case.

-- 
John Cowan  cowan@x   http://ccil.org/~cowan
"The exception proves the rule."  Dimbulbs think: "Your counterexample proves
my theory."  Latin students think "'Probat' means 'tests': the exception puts
the rule to the proof."  But legal historians know it means "Evidence for an
exception is evidence of the existence of a rule in cases not excepted from."

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