[R6RS] string->number
William D Clinger
will at ccs.neu.edu
Wed Aug 30 14:01:41 EDT 2006
Kent wrote:
> Treating (/ 0 x) as 0 is perfectly sensible if you believe that IEEE +0.0
> and -0.0 cannot be exactly 0.
Believing that IEEE +0.0 and -0.0 cannot be exactly 0
does not imply that the value of (/ 0 0.0) "is unaffected
by the inexactness of its arguments", which is the proof
obligation stated explicitly in R5RS 6.2.2.
> And if you believe that they can both be
> exact 0 and hence can both be the same, you'd better explain why the
> numeric values of (/ 1 +0.0) and (/ 1 -0.0) are so radically different.
I do not believe they are the same. Your continued harping
on this non-issue suggests that you do not understand the
proof obligation stated by either the R5RS or the R6RS.
> > > Is this new in R6RS?
> >
> > No. The behavior of (/ 0 0.0) in Chez Scheme and MzScheme
> > is as illegal under the R5RS semantics as under the R6RS.
>
> I disagree wrt R5RS semantics, and I've yet to find anything in the R6RS
> semantics that renders this behavior illegal.
Please read R5RS 6.2.2 and the draft of the R6RS section
currently titled "Propagation of exactness" (which ought
to be "Propagation of exactness and inexactness".)
> Indeed, the committed
> version of the R6RS specifically allows allows (/ 0 0.0) to evaluate to 0.
That is the deliberate error Mike and I would like to correct,
but will not because you object to its correction.
> > With the exception of inexact->exact, the operations
> > described in this section must generally return
> > inexact results when given any inexact arguments. An
> > operation may, however, return an exact result if it
> > can prove that the value of the result is unaffected
> > by the inexactness of its arguments. For example,
> > multiplication of any number by an exact zero may
> > produce an exact zero result, even if the other
> > argument is inexact.
>
> That's what I thought. But you claimed the proof would have to be made
> for "all substitutions of exact numbers for the inexact ones",
The R6RS language about "all possible substitutions of exact
arguments for the inexact ones" is just a clarification of
the R5RS language about "can prove that the value of the
result is unaffected by the exactness of its arguments."
That clarifying language has been in SRFI 77 for a long
time, and was proposed in our discussions as one of the
three guiding principles of R6RS arithmetic. That principle
met with no objection from readers of SRFI 77, and has met
with no objection from the R6RS editors. The arithmetic
proposal received preliminary approval by the R6RS editors
on 13 June 2006.
See https://r6rs.scheming.org/node/178
> which means
> that I can't reduce (/ 0 3.5) to 0 because if I were to substitute 0 for
> 3.5 in (/ 0 3.5) I would get (/ 0 0) which (we both agree) is not 0.
Reducing (/ 0 3.5) to an exact 0 is illegal in both the
R5RS and in the R6RS semantics. According to both the
R5RS and the draft R6RS, (/ 0 3.5) should reduce to an
inexact number, presumably 0.0, conceivably +nan.0 or
any other inexact number, but never to 0.
Note that this is different from (* 0 3.5), which we all
agree can be reduced to an exact 0.
> Perhaps you meant to imply some sort of equivalence in the substitution.
> But all exact equivalents of +0.0 and -0.0 are nonzero, so that would not
> preclude (/ 0 +0.0) from evaluating to 0.
No, you are misunderstanding the R5RS semantics. The +0.0
is inexact, so it is probably just an approximation to some
number that might well be negative. It is appropriate for
the result to be a guess of some sort, but guesses are not
allowed to be expressed as exact numbers; the guess must be
expressed as an inexact number.
> > That is another red herring. Everyone agrees that, for
> > all exact numbers x, an exact 0 is the correct result of
> > (* 0 x). Therefore everyone agrees that both the R5RS
> > and R6RS allow (* 0 x) to evaluate to an exact 0 for any
> > number x.
>
> Really? What about these two examples in base.tex:
>
> (* 0 +inf.0) \ev 0 \textit{or} +nan.0
> (* 0 +nan.0) \ev 0 \textit{or} +nan.0
Those examples illustrate exactly what I said: that both the
R5RS and R6RS *allow* (* 0 x) to evaluate to an exact 0 for
any number x.
Will
More information about the R6RS
mailing list