slib-discuss
[Top][All Lists]
Advanced

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

Re: [Slib-discuss] Several (minor) glitches in testing format feature.


From: Kris De Volder
Subject: Re: [Slib-discuss] Several (minor) glitches in testing format feature.
Date: Sun, 14 Dec 2008 15:20:40 -0800

On Sat, 2008-12-13 at 22:18 -0500, Aubrey Jaffer wrote:Not as I read R4RS:
> 
>  > An implementation of Scheme must support exact integers throughout
>  > the range of numbers that may be used for indexes of lists,
>  > vectors, and strings or that may result from computing the length
>  > of a list, vector, or string.
> 
> So exact integers are required.

I agree. This is how I also understood it. I think I just read
differently this section:

> 
>  > Implementations are encouraged, but not required, to support exact
>  > integers and exact rationals of practically unlimited size and
>  > precision, and to implement the above procedures and the `/'
>  > procedure in such a way that they always return exact results when
>  > given exact arguments.
> 
> That sentence is tautologous if an implementation has only exact
> numbers.

I interpreted the fact that "/" was in this paragraph instead of the one
describing + * etc. to be a concession to the fact that the result of
"/" is not always exactly representable as an integer. e.g (/ 3 2).

And I took the paragraph's starting with "encouraged but not required"
as basically allowing implementors to simply ignore this paragraph if
they so choose.

> 
>  > If one of these procedures is unable to deliver an exact result
>  > when given exact arguments, then it may either report a violation
>  > of an implementation restriction or it may silently coerce its
>  > result to an inexact number.
> 
> Because an implementation must provide exact integers, every
> implementation is capable of returning an exact result for (/ 6 2).

I agree your reading, where the "encouraged but not required" doesn't
apply to this section, makes more sense. So a fixnum implementation of /
is then required to return exact results when possible and only should
signal an error for things like (/ 3 2) which don't have an exact
integer result.

If this is the right interpretation, perhaps another test or two should
be added to r4rstest.scm. (e.g (/ 6 2) => 3)

> 
>  | 2) test in formattst.scm that test flonums without checking they
>  | are supported by the implementation:
>  | 
>  | (load "formatst.scm")
>  | ...
>  | error at line: 82 col: 1 in
>  | file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/formatst.scm
>  |     (test '("~a" -1.2) "-1.2")
>  | 
>  | I propose to change this line to:
>  |     (if format:floats (test '("~a" -1.2) "-1.2"))
> 
> But the implementation will still choke reading -1.2.  I think it
> needs to be:
> 
>   (if format:floats (test '("~a" (string->number "-1.2")) "-1.2"))

Even better. My reader "accidentally" parses -1.2 as something (not a
number) but this is really idiosyncratic.

> 
>  | 3) version discrepancy with sc4opt.scm?
>  | ...

Thanks for clearing that up. 

I'll summarize for the list: (correct me if I'm reading this wrong) 

 - The fact that the sc4 tests aren't run by default is so that the test
can be used for testing IEEE scheme compliant implementations. 

 - To be slib compatible however, an implementation must be fully R4RS
compliant and it *must* pass the sc4 tests. 






reply via email to

[Prev in Thread] Current Thread [Next in Thread]