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: Aubrey Jaffer
Subject: Re: [Slib-discuss] Several (minor) glitches in testing format feature.
Date: Sat, 13 Dec 2008 22:18:58 -0500 (EST)

 | From: Kris De Volder <address@hidden>
 | Date: Fri, 12 Dec 2008 16:46:45 -0800
 | 
 | I'm currently trying to get formatst.scm to pass and ran into some
 | problems.
 | 
 | I am posting them on the list because I think some of them may
 | point to possible problems in slib or at least an opportunity to
 | improve r4rsts.scm coverage. I also have some questions to help
 | clarify some details I'm not sure about.
 | 
 | 1) mularg glitch with "/" for a fixnum only Scheme implementation
 | 
 | I propose to add a test to r4rstest to check whether
 | (procedure? /) -> #t to r4rstest.scm

Done.

 | Background info: From the way the r4rs itself reads, and the
 | r4rstest.scm file works, it seems to me that there is an intention
 | to allow implementations that only support exact fixnum arithmetic.

Yes.  The "scmlit" build of SCM is such an implementation.

 | Currently my implementation is such an implementation and it passes
 | the r4rs test suite.
 | 
 | However, when I try to 
 | 
 | (require 'format)
 | 
 | > (require 'format)
 | slib:load "file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/format"
 | slib:load 
"file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/strcase"
 | slib:load "file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/sc4opt"
 | slib:load 
"file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/strport"
 | slib:load "file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/mularg"
 | ca.kscheme.interp.ErrorWithCont: Unbound identifier: / in
 | line: 9 col: 29 in 
file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/mularg.scm
 |  
 | I went and looked at the r4rs report and my interpretation w.r.t
 | "/" is that it is an "essential" procedure.  Thus even a strictly
 | fixnum implementation should provide a definition, but the
 | implementation may report an error if it is called with arguments
 | for which it cannot accurately represent the outcome of the
 | division.
 | 
 | Actually, the report only *recommends* that / when given exact
 | arguments should try to return exact results when possible.  It
 | does not actually require it.  Thus the report seems to demand that
 | / be implemented but would allow for a fixnum only implementation
 | to simply signal an error whenever it is called.

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.

 > 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.

 > 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).

 | 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"))

 | 3) version discrepancy with sc4opt.scm?
 | 
 | Unbound identifier: list->string
 | line: 268 col: 4 in
 | file:/home/kdvolder/workspaces/kscheme/ca.kscheme/bin/slib/format.scm
 | 
 | First I thought that it was a missing (require 'rev4-optional-procedures)
 | but the require is actually there.
 | 
 | Looking into "sc4opt.scm" I see no definition of list->string however. 
 | 
 | I did find that this page:
 | http://www.cs.indiana.edu/scheme-repository/SCM/slib_5.html
 | 
 | tells there ought to be one.
 | 
 | But the more recent page at
 | http://people.csail.mit.edu/jaffer/slib_7.html
 | 
 | doesn't mention list->string
 | 
 | Looking in the r4rs report, it seems that it is an essential procedure,
 | which is probably why it was removed from sc4opt.scm.
 | 
 | Nevertheless in the r4rs test suite it is only tested for in the
 | "optional" test-sc4 procedure.

Don't confuse r4rs-optional procedures and test-sc4.
Line 38 of "r4rstest.scm" explains:

  ;;; (TEST-SC4) tests procedures required by R4RS but not by IEEE

IEEE being IEEE-1178 Scheme.

 | I resolved the issue for me by providing my own list->string
 | implementation and be more compliant with r4rs by making sure I
 | pass the sc4 tests.
 | 
 | I've got two specific questions about something that's not quite clear
 | to me here: 
 | 
 |   1) is there still an implementation of list->string provided in
 |      slib somewhere?

No.

 |   2) is slib supposed to work with an implementation that doesn't
 |      pass the sc4 tests?

No.  SLIB is built on R4RS, not IEEE-1178.  If there were an
implementation supporting IEEE-1178, but not R4RS, then its *.init
file would need to define list->string, string->list, vector->list,
and list->vector.




reply via email to

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